# App Shell

> The frame of an app: navigation on the frame (a sidebar with navigation="sidebar", or a top bar) and the page on a sheet beside it, with an optional side panel and dock.

Component · Navigation · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/AppShell/)

The frame of an app: navigation on the frame (a sidebar with `navigation="sidebar"`, or a top bar)
and the page on a sheet beside it, with an optional side panel and dock.

- `sidebarGroups`, `active` and `onNavigate` drive the sidebar; `workspaces` puts a workspace switcher
  and `user` with `userMenu` a user menu on it.
- The shell reflows by its own width (container queries), so it also works inside a smaller area.
- `fill` makes the shell the whole page: at least the viewport's height (`100dvh`), no outer radius,
  the sheet takes the rest of the height. On desktop the sidebar stays in view while the page
  scrolls; on phones the sheet starts right under the sidebar's bar.
- `brandDot={false}` drops the status dot after the brand, e.g. next to a logo of your own.
- With `fill` the page itself scrolls and the sidebar (and the top bar) stick to it. Do not put
  `overflow-x: hidden` on `html` or `body`: it turns `body` into a scroll container that never
  scrolls, and the sticky parts scroll away with the page. Use `overflow-x: clip` to cut off
  sideways overflow instead.

```tsx
// app/admin/layout.tsx: the shell is the page
<AppShell fill navigation="sidebar" brand="Admin" sidebarGroups={groups} active={section}
  user={{ name, email }} dock={false}>
  {children}
</AppShell>
```

## Top bar

`topbar` adds a bar across the top of the frame in sidebar mode. The brand (or `workspaces`) moves
into its start and is exactly as wide as the sidebar below it, expanded or collapsed, so both read
as one column. `topStart` follows the brand (a `SearchField` or a command palette trigger), `topEnd`
sits at the end (buttons, menus). Frame, bar and sidebar form one L around the sheet; the sheet
starts under the bar, rounded where it meets them.

- With `fill` the bar and the sidebar stay in view while the sheet scrolls under the bar.
- On phones the bar is the sidebar's bar (menu button and brand) with `topEnd` on the right.
  `topStart` sits behind an icon button (`topStartIcon`, `topStartLabel`) and opens over the bar;
  Escape closes it. Pass `topStartCompact` to show something else there, e.g. an `IconButton`
  that opens your command palette.
- Content given to `topbar` itself goes between `topStart` and `topEnd`. `topExtra` goes to the
  bar's end; without the bar it stays at the top of the sheet as before.
- On glass the bar sits on the glass frame like the sidebar: frame, bar and sidebar are one pane.
  With `fill` the sheet scrolls under the bar, so the bar blurs what passes under it
  (`--glass-blur`) without adding a tint of its own. For that the pane is drawn on a layer behind
  the shell's content rather than on the shell itself (a backdrop-filter on the shell would make
  every filter inside it see only the shell).
- On phones the sidebar opens as a drawer over the page; on glass it blurs what lies under it
  (`--glass-filter`), so the page never shows sharply through the menu.

```tsx
<AppShell fill navigation="sidebar" topbar brand="Admin" sidebarGroups={groups} active={section}
  topStart={<SearchField placeholder="Search orders" shortcut="⌘K" bindShortcut />}
  topEnd={<><IconButton icon="bell" label="Notifications" variant="ghost" /><Button size="sm" variant="secondary">New order</Button></>}
  user={{ name, email }} dock={false}>
  {children}
</AppShell>
```

## Example

```tsx
import {
  AppShell,
  Button,
  IconButton,
  PageHeader,
  Panel,
  SearchField,
} from "@twentyfirstmedia/pro";
import type { SidebarGroup } from "@twentyfirstmedia/pro";

const GROUPS: SidebarGroup[] = [
  {
    items: [
      { id: "home", label: "Home", icon: "home" },
      { id: "orders", label: "Orders", icon: "cart", badge: "12" },
      { id: "customers", label: "Customers", icon: "users" },
    ],
  },
  {
    label: "Settings",
    items: [
      { id: "team", label: "Team", icon: "user" },
      { id: "billing", label: "Billing", icon: "card" },
    ],
  },
];

export default function Preview() {
  return (
    <AppShell
      navigation="sidebar"
      topbar
      brand="Admin"
      topStart={<SearchField placeholder="Search orders" shortcut="⌘K" />}
      topEnd={
        <>
          <IconButton icon="bell" label="Notifications" variant="ghost" />
          <Button size="sm" variant="secondary">
            New order
          </Button>
        </>
      }
      sidebarGroups={GROUPS}
      active="orders"
      user={{ name: "Mara Ellis", email: "mara@example.com" }}
      dock={false}
    >
      <div className="tf-in">
        <PageHeader title="Orders" subtitle="12 waiting to ship" />
      </div>
      <Panel title="Today">
        <p style={{ margin: 0, color: "var(--ink-muted)" }}>
          The content of the page goes into the sheet.
        </p>
      </Panel>
    </AppShell>
  );
}
```

## Props

### AppShell

| Prop | Type | Notes |
| --- | --- | --- |
| `active?` | `string` |  |
| `brand?` | `ReactNode` | The product name, or a node (a logo mark with the name; collapsed sidebars show it whole). |
| `brandDot?` | `boolean` | The status dot after the brand (default `true`); turn it off next to a logo of your own. |
| `tag?` | `string` |  |
| `nav?` | `NavItem[]` |  |
| `user?` | `{ name: string; email?: string }` |  |
| `onNavigate?` | `(label: string) => void` |  |
| `topExtra?` | `ReactNode` |  |
| `sheetStyle?` | `CSSProperties` |  |
| `contentKey?` | `string \| number` |  |
| `side?` | `ReactNode` |  |
| `dock?` | `boolean` |  |
| `dockItems?` | `DockProps["items"]` |  |
| `railTop?` | `RailItem[]` |  |
| `railBottom?` | `RailItem[]` |  |
| `fill?` | `boolean` | The shell is the whole page: at least the viewport's height (100dvh), no outer radius, the sheet fills the rest; on desktop the sidebar stays in view while the page scrolls, on phones the sheet starts right under the sidebar's bar. |
| `navigation?` | `"top" \| "sidebar"` |  |
| `sidebarGroups?` | `SidebarGroup[]` | With `navigation="sidebar"`: groups instead of the flat `nav` list. |
| `sidebar?` | `Partial<Omit<SidebarProps, "variant" \| "groups">>` | With `navigation="sidebar"`: more sidebar props (collapsed, storageKey, shortcut, linkAs …). |
| `workspaces?` | `WorkspaceSwitcherProps` | With `navigation="sidebar"`: the workspace switcher at the top instead of the brand. |
| `userMenu?` | `(MenuItem \| "-")[]` | The account menu's entries (with `navigation="sidebar"` at the foot of the sidebar). |
| `topbar?` | `boolean \| ReactNode` | With `navigation="sidebar"`: a bar across the top of the frame. The brand (or `workspaces`) moves into its start, as wide as the sidebar below it (expanded or collapsed); `topStart` follows it, `topEnd` sits at the end. Frame, bar and sidebar read as one L around the sheet. Content given here goes between `topStart` and `topEnd`. On phones the bar is the sidebar's bar (menu button and brand) with `topEnd` on the right and `topStart` behind an icon button. |
| `topStart?` | `ReactNode` | With `topbar`: right after the brand, e.g. a search field or a command palette trigger. |
| `topEnd?` | `ReactNode` | With `topbar`: at the end of the bar (buttons, menus); `topExtra` goes there too. |
| `topStartCompact?` | `ReactNode` | With `topbar` on phones: what stands in for `topStart` (default: an icon button that opens `topStart` over the bar). |
| `topStartIcon?` | `IconName` | The icon of that button (default `search`). |
| `topStartLabel?` | `string` | The accessible name of that button (default "Search"). |
| `children?` | `ReactNode` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### PageHeader

| Prop | Type | Notes |
| --- | --- | --- |
| `crumbs?` | `(string \| Crumb)[]` | A breadcrumb above the title (see `Breadcrumb`): labels, or items with `href`/`onClick`. |
| `crumbLinkAs?` | `ElementType` | The element crumb links render as, e.g. Next.js `Link`. |
| `title` | `string` | Required |
| `subtitle?` | `string` |  |
| `actions?` | `ReactNode[]` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Panel

| Prop | Type | Notes |
| --- | --- | --- |
| `side?` | `boolean` |  |
| `title?` | `string` |  |
| `subtitle?` | `string` |  |
| `action?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `surface?` | `Surface` | `"glass"`: translucent glass over what is behind (maps, 3D, video, photos); `"solid"` opts out inside a glass `UIProvider`. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
