Shell
BsShell is a responsive app-shell layout with a collapsible sidebar. Put the sidebar in the #sidebar slot and the top-bar content in #topbar; the default slot is 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 slot) sits above the sidebar/content row. breakpoint sets the viewport width at/above which the sidebar is expanded; size is the expanded width.
<script setup lang="ts">import { BsShell } from '@mintplayer/vue-bootstrap/shell';</script><template> <BsShell breakpoint="md" size="14rem" class="app-shell"> <!-- The shell renders the hamburger at the top bar's left; the #topbar slot fills the rest (brand, nav, …). --> <template #topbar><div>Brand · nav</div></template> <!-- The #sidebar slot is the collapsible sidebar. --> <template #sidebar><nav>…links…</nav></template> <!-- The default slot is the main content area. --> <main><RouterView /></main> </BsShell></template>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 class 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; class/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 @state-change (its open is the resolved visual state).
<script setup lang="ts">import { ref } from 'vue';import { BsShell, type ShellStateChange } from '@mintplayer/vue-bootstrap/shell';import { installBootstrap } from '@mintplayer/ui-core/bootstrap';import { bootstrapTablesPage } from '@mintplayer/ui-core/bootstrap/tables';// Raw Bootstrap markup on this page: it installs the verbatim parts itself, never globally (#452).installBootstrap(bootstrapTablesPage);// 'auto' is responsive; 'show'/'hide' force the sidebar open/closed.const state = ref<'auto' | 'show' | 'hide'>('auto');function onStateChange({ open }: ShellStateChange) { state.value = open ? 'show' : 'hide';}</script><template> <BsShell breakpoint="md" :state="state" @state-change="onStateChange"> <template #sidebar><nav>…</nav></template> <main>…</main> </BsShell></template>External toggle
Set external-toggle 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 (a template ref exposes toggle(force?)). --><BsShell ref="shell" external-toggle breakpoint="md"> <template #sidebar><nav>…</nav></template> <main>…</main></BsShell>API
| Prop | Type | Default | Description |
|---|---|---|---|
state | 'auto' | 'show' | 'hide' | 'auto' | Sidebar visibility; auto is responsive. |
breakpoint | 'xs'…'xxl' | 'md' | Viewport width at/above which auto expands the sidebar. |
size | CSS length | 15rem | Expanded sidebar width (also settable via --mp-shell-size). |
external-toggle | boolean | false | Hide the built-in hamburger; drive the toggle from your own control. |
dismiss-on-navigate | boolean | false | Auto-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. |
@state-change | (change: {'{'} open: boolean {'}'}) => void | — | Fires when the toggle flips. |
Slots: topbar, sidebar, and the default (unnamed) slot for main content.