App Shell
FreeThe frame of a dashboard: a collapsible sidebar, a top bar, the page and a footer — slot-based, with the collapsed and mobile-overlay state shared by the parts without a single binding.
import { SvDashboardShellComponent } from '@styloviz/layout/dashboard-shell';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Sidebar (shell)
<!-- The collapsible container: a brand row, your navigation, a pinned footer. Inside a shell it follows the shell's collapsed / mobileOpen state. --> <sv-sidebar svShellSidebar label="Main navigation"> <a svSidebarBrand routerLink="/">Acme</a> <nav aria-label="Primary">…</nav> <span svSidebarFooter>v3.1</span> </sv-sidebar>
Sidebar Nav (tree)
<!-- The navigation tree inside it: groups, sub-navigation, the active trail and the rail. Its own chrome and drawer are off — the sidebar is both. --> <sv-sidebar svShellSidebar> <sv-sidebar-nav [menuGroups]="nav" [activeRoute]="router.url" [collapsed]="shell.collapsed()" [showHeader]="false" [showFooter]="false" [mobileBreakpoint]="0" /> </sv-sidebar>
Page header with actions
<sv-page-header title="Orders" subtitle="1,284 this month"> <sv-button variant="secondary" label="Export" /> <sv-button label="New order" /> </sv-page-header>
Persist the collapsed rail
<!-- collapsed and mobileOpen are models: bind them to keep the rail across reloads --> <sv-dashboard-shell [(collapsed)]="railed">…</sv-dashboard-shell>
Embedded in a page or preview
<!-- contained: fill the container, not the viewport --> <div class="h-[480px]"> <sv-dashboard-shell [contained]="true">…</sv-dashboard-shell> </div>
Skip link
<!-- On by default: the first Tab stop is "Skip to main content", which moves focus to <main>. Rename it, or turn it off when the page renders its own. --> <sv-dashboard-shell skipLinkLabel="Skip to orders">…</sv-dashboard-shell> <sv-dashboard-shell [skipLink]="false">…</sv-dashboard-shell>
A layout without a sidebar
<sv-dashboard-shell> <sv-topbar svShellTopbar [showSidebarToggle]="false"><span topbar-start>Acme</span></sv-topbar> <router-outlet /> </sv-dashboard-shell>
Page header with navigation and responsive actions
<!-- With a breadcrumb, back/up or tabs slot the header is ONE region landmark named by its title. [actions] fold into the toolbar's "More actions" menu when the row runs out of room; projected buttons render beside them. --> <sv-page-header title="Order #1042" subtitle="Placed 3 March" [actions]="actions" (actionClick)="run($event)"> <sv-back-up svPageHeaderBack mode="up" [up]="'/orders'" upLabel="Orders" size="sm" /> <sv-breadcrumb svPageHeaderBreadcrumb [items]="trail" /> <span svPageHeaderMeta>Paid</span> <sv-button label="Refund" /> <sv-tabs svPageHeaderTabs [tabs]="tabs" size="sm" /> </sv-page-header>
When to use
The outer frame of an admin panel, a SaaS dashboard or an internal tool: navigation on the side, actions on top, the page in between. You want the collapsed rail and the small-screen overlay handled once, for every page, instead of per page. Use `sv-page-header` at the top of each routed page for its title, subtitle and primary actions. Sidebar (shell) · Sidebar Nav (tree): `sv-sidebar` is the collapsible container, and Sidebar Nav (`sv-sidebar-nav`, a variant of this family) is the navigation tree you put inside it. Compare with Site Footer: `sv-footer` is the one-line bar inside the shell; `sv-site-footer` is the multi-column marketing footer.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| collapsed | boolean (two-way) | false | Desktop: the sidebar is collapsed to its icon rail. Two-way. |
| mobileOpen | boolean (two-way) | false | Small screens: the sidebar is open as an overlay. Two-way. |
| contained | boolean | false | Fill the container instead of the viewport, for a shell embedded in a page. |
| skipLink | boolean | true | Render the "Skip to main content" link (WCAG 2.4.1 Bypass Blocks) as the shell's first focusable element. Turn it off only when the page already renders its own skip link — two would be one too many. |
| skipLinkLabel | string | 'Skip to main content' | Text of the skip link. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| collapsedChange | boolean | Emits the new `collapsed` whenever it changes — the output half of `[(collapsed)]`. |
| mobileOpenChange | boolean | Emits the new `mobileOpen` whenever it changes — the output half of `[(mobileOpen)]`. |
<sv-sidebar>
Also in this family — SvSidebarComponent from @styloviz/layout.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| collapsed | boolean | false | Collapsed to the icon rail (desktop). Ignored inside `sv-dashboard-shell`, which owns it. |
| mobileOpen | boolean | false | Open as an overlay (small screens). Ignored inside `sv-dashboard-shell`, which owns it. |
| label | string | 'Main navigation' | Accessible name of the panel. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| mobileClose | void | Emits when the overlay should close: a link inside it was activated, or Escape was pressed. |
<sv-topbar>
Also in this family — SvTopbarComponent from @styloviz/layout.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| sidebarCollapsed | boolean | false | Whether the sidebar is collapsed, for the toggle's icon and pressed state. Ignored inside `sv-dashboard-shell`. |
| showSidebarToggle | boolean | true | Render the sidebar toggles. Set false for a layout without a sidebar. |
| showThemeToggle | boolean | true | Render the light/dark toggle. |
| openSidebarLabel | string | 'Open sidebar' | Accessible name of the small-screen hamburger. |
| expandSidebarLabel | string | 'Expand sidebar' | Accessible name of the desktop toggle while the sidebar is collapsed. |
| collapseSidebarLabel | string | 'Collapse sidebar' | Accessible name of the desktop toggle while the sidebar is expanded. |
| lightModeLabel | string | 'Switch to light mode' | Accessible name of the theme toggle in dark mode. |
| darkModeLabel | string | 'Switch to dark mode' | Accessible name of the theme toggle in light mode. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| toggleSidebar | void | Emits when the desktop sidebar toggle is activated. |
| toggleMobileSidebar | void | Emits when the small-screen hamburger is activated. |
<sv-page-header>
Also in this family — SvPageHeaderComponent from @styloviz/layout.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| titlerequired | string | — | Page title |
| subtitle | string | '' | Optional subtitle / description |
| actions | readonly PageHeaderAction[] | [] | Actions for the responsive actions row, rendered through `sv-toolbar` with `overflow="menu"`: what does not fit the row folds into a "More actions" menu. Projected buttons (the default slot) render beside them. |
| actionsLabel | string | 'Page actions' | Accessible name of the actions row. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| actionClick | string | Emits the `id` of the action chosen from the actions row or its overflow menu. |
Customization & theming
Slots: `[svShellSidebar]`, `[svShellTopbar]`, the default slot (the page), `[svShellFooter]`. A shell with no sidebar takes no left offset. `sv-sidebar`: `[svSidebarBrand]` (the 64 px brand row), the default slot (navigation) and `[svSidebarFooter]` (pinned to the bottom); `w-64` expanded, a `w-20` rail collapsed from `lg` up, an overlay below it. `sv-topbar`: the sidebar toggles, then `[topbar-start]`, `[topbar-search]` (the flexible middle), `[topbar-actions]`, then the theme toggle. `showSidebarToggle` and `showThemeToggle` turn the built-in controls off. `sv-footer`: the default slot (start) and `[svFooterEnd]` (end); stacked on small screens. Every surface uses the theme tokens with a `dark:` counterpart; the sidebar and topbar are glass because the page scrolls beneath them. `sv-page-header`: `title` and `subtitle`; slots `[svPageHeaderBack]` and `[svPageHeaderBreadcrumb]` above the title, `[svPageHeaderMeta]` beside it, `[svPageHeaderTabs]` along the bottom edge, the default slot for actions; `actions` (+ `actionClick`, `actionsLabel`) for a responsive actions row that folds into the toolbar's overflow menu. Import the slot directives (`SvPageHeaderBreadcrumbDirective`, …) so the header knows it holds page navigation.
Best practices
Do: Put your `<router-outlet />` in the shell's default slot: it is the scrolling region, so the topbar stays put while the page scrolls. Do: Let the shell own the state. A projected `sv-sidebar` and `sv-topbar` read and drive it through `SV_SHELL_CONTEXT`; bind `[(collapsed)]` only when you need to persist or set it. Do: Pass a nav component's own collapsed input from the shell (`[collapsed]="shell.collapsed()"`) so the tree and the rail agree, and turn its own mobile drawer off (`[mobileBreakpoint]="0"`) — the sidebar already is one. Don't: Don't nest a shell inside a page that already has one; use `contained` only for a shell embedded on purpose (a preview, a docs page, a panel). Tip: Toasts are not part of the shell: add the `<sv-toast-host>` positions you use next to it. Do: Keep the built-in skip link (on by default). If the page already renders its own "Skip to content" link, set `[skipLink]="false"` — two skip links in a row are one too many.
Accessibility
Landmarks: the sidebar is a `complementary` region named by `label` (default "Main navigation"), the topbar a `banner`, the page `main`, the footer `contentinfo`. Put a named `<nav>` inside the sidebar. The desktop toggle reports `aria-pressed` and is named for what it will do ("Collapse sidebar" / "Expand sidebar"); the hamburger and the theme toggle are named too, and every name is an input for translation. The small-screen overlay closes on Escape, on its backdrop (hidden from assistive technology) and when a link inside the sidebar is followed. Collapsed, the navigation is the nav component's job: `sv-sidebar-nav` keeps every item named in its rail. Skip link (WCAG 2.4.1): the shell's first focusable element is a "Skip to main content" link, visually hidden until it takes focus. Activating it moves focus to `<main>` (which has `tabindex="-1"`), so the next Tab continues inside the page instead of walking the sidebar and topbar again. Its text comes from the `layout` label pack (`skipToMainContent`, all 12 languages); `skipLinkLabel` overrides it, `skipLink` turns it off, and `focusMain()` lets a host shortcut do the same move. RTL: the sidebar is pinned to the inline start (`start-0`, border on the inline end) and the content is offset with `margin-inline-start`, so under `dir="rtl"` the sidebar is on the right and the page makes room on the right; the small-screen overlay slides off to the right. `sv-page-header`: the title is the page `<h1>`. With a breadcrumb, back/up or tabs slot in use the header is one `region` landmark named by that title, so the page's own navigation sits in one place; a plain header adds no landmark. The actions row is a named `toolbar` ("Page actions") whose overflow is the kit's keyboard-operable "More actions" menu.
Feedback on App Shell
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.