App shell
An app's frame: a full-height sidebar you can resize in steps beside a page box that scrolls on its own, a ⌘K command palette, and a menu sheet on phones.
npx shadcn@latest add @silicon-ui/app-shellInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/app-shellManually
Install the dependencies
npm install lucide-reactCopy these files into your project
- components/silicon-ui/app-shell/app-shell.tsx
- components/silicon-ui/app-shell/app-shell.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/sidebar-rail.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
brand*The product's wordmark, usually a link home. At the sidebar's head from 900px, in the top bar under 900px. | ReactNode | — |
nav*The sidebar's destinations, usually a NavList (size "md"). | ReactNode | — |
children*The page. It is drawn in the page box, the only thing that scrolls from 900px. | ReactNode | — |
searchUnder the brand, above the navigation: a search field, for an app whose content people search (the Apps store's apps): usually a SearchField with `hideLabel` in a GET form, so it works without script. Search is not the command palette: with `commands` too, the field takes this place and ⌘K still opens the palette. Without it, `commands` draws the shell's own Search row here, which opens the palette. | ReactNode | — |
accountAt the sidebar's foot: the signed-in account (a UserMenu or a profile switcher, a link to settings) or a sign-in button. Pass a function to draw it per place: a menu that opens upward beside the page, and its rows listed in place in the phone menu, so a phone never opens a second sheet over the first. | ReactNode | ((place: AppShellPlace) => ReactNode) | — |
linksUnder the account, over a hairline: links to other sites, usually soft `xs` ButtonLinks. | ReactNode | — |
onNavigateCalled when a link in the brand, search, nav, account or links is followed with a plain click, after the phone menu starts to close. Call `event.preventDefault()` to run your own guards or transitions instead of the browser's navigation. Modified clicks (a new tab) don't call it. | (navigation: AppShellNavigation) => void | — |
stepsThe sidebar's widths in px, narrowest first. With more than one, a handle on the page box's edge steps between them (drag, arrow keys, Home and End; a double-click goes back to `defaultStep`). | number[] | DEFAULT_STEPS |
defaultStepIndex into `steps` the sidebar starts at. Defaults to the middle step. | number | — |
storageKeyRemembers the chosen width in this browser's localStorage under this key (and whether the rail is on, under `{storageKey}:rail`). Without it the width resets on reload. | string | — |
railLets the sidebar fold into a rail: its icons alone, the words in a tip beside each. Dragging the handle narrower than the first step or ⌘B (Ctrl B elsewhere) folds it; the same widen it back to the last width. In the rail NavList rows are icons (a row without one is left out), a section that can't be icons (one that opens and closes, holds sections, or has rows without icons) is its icon that opens it in a flyout (left out when it has no icon), AccountMenu is the photo, `search` is a button that widens the sidebar and goes to the field, and `links` are hidden. Phones always get the whole sidebar. | boolean | false |
defaultRailStarts in the rail (until the person changes it, when `storageKey` remembers their choice). | boolean | false |
brandMarkThe brand's mark alone, for the rail's head: a square logo, usually the same link home. Without it the rail's head shows the start of `brand`. | ReactNode | — |
sidebarLabelNames the sidebar for screen readers. | string | "Sidebar" |
menuLabelThe phone menu's title and the menu button's name. | string | "Menu" |
linksLabelNames the `links` navigation for screen readers. | string | "Other sites" |
skipLabelThe skip link's words; it moves focus to the page box. | string | "Skip to content" |
mainIdThe page box's id, the skip link's target. | string | "main" |
commandsThe command palette's commands. With any, ⌘K (Ctrl K elsewhere) opens and closes the palette, in a headerless dialog near the top of the window, and `useAppShell().openCommands()` opens it from a slot. | CommandItem[] | — |
onCommandCalled with the chosen command, once the palette has started to close (so focus is back before the command moves it). | (item: CommandItem) => void | — |
commandsOpenWhether the palette is open, to control it (with `onCommandsOpenChange`). | boolean | — |
onCommandsOpenChangeCalled when the palette opens or closes: ⌘K, the Search button, Escape, or a choice. | (open: boolean) => void | — |
commandsLabelThe palette's name for screen readers, and the Search button's. | string | "Search pages and actions" |
commandsPlaceholderThe palette's field placeholder. | string | "Search pages and actions" |
searchLabelThe shell's own Search button's words. | string | "Search" |
classNamePlacement only, on the shell's root. | string | — |