Shell

BsShell is a responsive app-shell layout with a collapsible sidebar. Pass the sidebar as the sidebar prop and the top-bar content as topbar; the children are the main content area. It renders plain HTML on the server, and the open state is a native checkbox, so the sidebar and its hamburger toggle work with JavaScript disabled. The chrome around this very page is a live BsShell.

Basic usage

A full-width top bar (built-in hamburger + topbar prop) sits above the sidebar/content row. breakpoint sets the viewport width at/above which the sidebar is expanded; size is the expanded width.

import { BsShell } from '@mintplayer/react-bootstrap/shell';export function AppShell({ children }: { children: React.ReactNode }) {  return (    <BsShell      breakpoint="md"      size="14rem"      className="app-shell"      // The shell renders the hamburger at the top bar's left;      // `topbar` fills the rest (brand, nav, …).      topbar={<div>Brand · nav</div>}      // `sidebar` is the collapsible sidebar.      sidebar={<nav>…links…</nav>}    >      {/* The children are the main content area. */}      <main>{children}</main>    </BsShell>  );}

Full-height layout

The content is the scroll region only when the host has a bounded height. Give BsShell a viewport height — anything you pass via className or style falls through to the element.

/* The shell becomes its own scroll region (top bar + sidebar stay put,   only the content scrolls) ONLY when the host has a bounded height —   otherwise it grows to fit its content. Give it the viewport height;   className/style on <BsShell> fall through to the underlying element. */.app-shell {  height: 100dvh;}

Controlled state

Leave state as "auto" for responsive behaviour, or drive it yourself and react to onStateChange (its open is the resolved visual state).

import { useState } from 'react';import { BsShell } from '@mintplayer/react-bootstrap/shell';function Layout() {  // 'auto' is responsive; 'show'/'hide' force the sidebar open/closed.  const [state, setState] = useState<'auto' | 'show' | 'hide'>('auto');  return (    <BsShell      breakpoint="md"      state={state}      onStateChange={({ open }) => setState(open ? 'show' : 'hide')}      sidebar={<nav>…</nav>}    >      <main>…</main>    </BsShell>  );}

External toggle

Set externalToggle to hide the built-in hamburger and toggle the shell from your own button.

// Hide the built-in hamburger and drive the toggle from your own control// (the ref exposes toggle(force?)).<BsShell ref={shellRef} externalToggle breakpoint="md" sidebar={<nav>…</nav>}>  <main>…</main></BsShell>

API

PropTypeDefaultDescription
state'auto' | 'show' | 'hide''auto'Sidebar visibility; auto is responsive.
breakpoint'xs'…'xxl''md'Viewport width at/above which auto expands the sidebar.
sizeCSS length15remExpanded sidebar width (also settable via --mp-shell-size).
externalTogglebooleanfalseHide the built-in hamburger; drive the toggle from your own control.
dismissOnNavigatebooleanfalseAuto-close the overlay drawer when a sidebar link is clicked (narrow mode only). Mark a link (or a wrapper) with data-no-dismiss to exclude it — e.g. a parent that only expands a sub-list.
onStateChange(change: { open: boolean }) => void—Fires when the toggle flips.

Content: the topbar and sidebar props (React nodes), and children for the main content.