<!-- generated by scripts/gen-docs.mjs from docs/system/sidebar.md. Edit the source and rerun. -->
# Sidebar

## Description
Frames an app: the product's places in groups down one side, a bar above the page, and the page itself, with the side folding to a rail of glyphs and opening as a sheet on a phone.

`import { AppShell, AppShellHeader, AppShellMain, Sidebar, SidebarBody, SidebarFooter, SidebarGroup, SidebarHeader, SidebarItem, SidebarTrigger, useSidebar } from "@/components/cobalt/ui/sidebar"`, source `registry/cobalt/ui/sidebar.tsx`, status `ready-with-gaps`.
Foundation: `hand-rolled (the sheet on Sheet, a Base UI Drawer; collapsible groups on Collapsible; rail names on Tooltip; the trigger on IconButton)`. Traps checked: `trap/current-unmarked`, `trap/narrow-hidden-nav`, `trap/link-as-button`, `trap/weight-shift`, `trap/safe-area`, `trap/viewport-height`, `trap/motion-layout-property`, `trap/motion-frequent`, `trap/reduced-motion-ignored`, `trap/hover-unguarded`, `trap/list-dead-gap`, `trap/overlay-title`, `trap/overlay-focus-return`, `trap/focus-ring-shape`, `trap/text-measure`.

`trap/current-unmarked` is answered by `aria-current="page"` on the current place, drawn as the pill that slides to it from the last place, the `--thumb` fill in the column and the grey fill in the sheet (States, Motion). `trap/narrow-hidden-nav` by the folded rail, whose glyphs keep every place, and the sheet below 640px, so every place stays one press away at any width (Rules). `trap/link-as-button` by real links through `renderLink` for places, and buttons only for the workspace and account menus (Rules). `trap/weight-shift` by one weight for every row, current or not (States). `trap/safe-area` by the sheet's own bottom inset on a phone. `trap/viewport-height` by `h-dvh` on the shell. `trap/motion-layout-property` is the one exception the fold makes: the column's width moves, because the page beside it must take the room; everything inside keeps the open width, so only the edge moves (Motion, measured). `trap/motion-frequent` by animating only a fold the person asks for, never a resize, a restored fold or a page change. `trap/reduced-motion-ignored` by `motion-reduce:transition-none` on every moving part. `trap/hover-unguarded` by Tailwind's `(hover: hover)` guard. `trap/list-dead-gap` by rows that are the whole target. `trap/overlay-title` by the sheet's title, the sidebar's label. `trap/overlay-focus-return` by the Sheet, which returns focus to the trigger. `trap/focus-ring-shape` by the ring on the row's holder, on its corner. `trap/text-measure` by labels cut with an ellipsis at 170px and named whole in the tooltip (Limits).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| `Sheet` from `registry/cobalt/ui/sheet.tsx`: a side sheet from 640px up and a bottom sheet with a grabber below, swipe to dismiss, the portal, the scrim and focus return | The whole frame: `AppShell` reads its own width (a container, `@container/shell`, and a ResizeObserver for the behaviour), so a shell in a frame behaves as it would in a window; below 40rem no column, from 40rem the 240px column, or the 60px rail once the person folds it; the fold kept on `data-folded`, under `storageKey` in the browser, or controlled; `data-moving` only for the 450ms after the person's own fold, so nothing else animates |
| `Collapsible` from `registry/cobalt/ui/collapsible.tsx`: the panel that opens on the layout spring and closes on the settle spring, with its chevron | `SidebarGroup collapsible`: the heading as the trigger, its rows as a labelled group; in the rail the heading fades, keeps its 32px and leaves the tab order (`inert`) |
| `Tooltip` from `registry/cobalt/ui/tooltip.tsx`, and `isTruncated` from `registry/cobalt/lib/truncated-text.tsx` | A tooltip on each row that opens in the rail, or when the open label is cut, and names the place with its count in words |
| `IconButton` from `registry/cobalt/ui/icon-button.tsx` | `SidebarTrigger`: the panel glyph from 640px, the menu glyph on a phone, a name that says what the press does, and `shortcut` bound through `registry/cobalt/lib/shortcuts.ts` with `aria-keyshortcuts` |
| Not applicable: hand-rolled. The column, the rows and the fold | Every row keeps the open width, 216px, inside a holder that clips it, so folding covers the words and the count where they stand instead of moving them; the holder draws the keyboard ring; the count as a `Badge` capped at 99+ that fades with the words, and a 10px accent mark at the glyph's corner that shows only in the rail; the current place's pill, one `aria-hidden` span in each of the header, the body and the foot measured from the row with `aria-current` through `registry/cobalt/lib/use-indicator.ts` (`axis: "y"`, the place as its `scope`) and slid on `duration-settle ease-settle`, under the rows, the only fill a place takes (D43); each region clips its own pill (`overflow-clip`, and the body's scrolling box at least the body's height), so a place chosen in another region reads as one pill crossing between them; the pill's fill keeps the row holder's width and narrows with the fold |

## Examples
A research tool's frame with its places in groups beside a fund's page, the notifications in the header and the keyboard shortcuts a key away; folded, it is a rail of glyphs; on a phone the header's menu opens the places as a sheet.

Real uses, 0 call sites (`rg -n "<Sidebar\b" app registry --glob '!registry/cobalt/ui/*'`): the part is new. Every scene in the blocks drew its own frame before it (`docs/research/2026-10-17-missing-parts.md`, F1); the frame here takes from Tag's sidebar (`~/tag/src/owner-ui/Sidebar.svelte`), its fold and its narrow-window rule (`~/tag/src/owner-ui/Workspace.svelte`), and TSA's unread counts (`~/tsaglobal-superapp-live/apps/web/app/components/app-shell.tsx`).

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/sidebar/default.tsx` | default | A research tool's frame: places in groups beside a fund's page, the inbox in the header, the fold from the header's control or its shortcut, and the sheet below 640px |
| `docs/system/examples/sidebar/folded.tsx` | state:folded | A shell that opens folded, as the person left it, kept under a storage key |
| `docs/system/examples/sidebar/default.tsx` | state:sheet | Below 640px the header's menu opens the places as a bottom sheet; choosing one closes it |
| `docs/system/examples/sidebar/default.tsx` | state:counted | Inbox and Filings carry counts, 99+ past 99, and a mark in the rail |
| `docs/system/examples/sidebar/default.tsx` | state:group-closed | The Saved group closes to its heading and opens again |
| `docs/system/examples/sidebar/default.tsx` | layout=page | A fund's page centred in the main area, scrolling under the header |
| Not applicable: the List and detail page shows it, `docs/system/examples/list-detail/in-shell.tsx`, where the main area holds the list and the detail | layout=fill | The whole main area handed to a layout that scrolls its own parts |
| `docs/system/examples/sidebar/default.tsx` | composition:PageColumns | The page in the main area is a PageHeader, a Nav of the fund's views and PageColumns with a rail card |
| `docs/system/examples/sidebar/default.tsx` | composition:Inbox | The notifications open from the header |

Example: A research tool's frame: places in groups beside a fund's page, the inbox in the header, the fold from the header's control or its shortcut, and the sheet below 640px (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

Example: The page in the main area is a PageHeader, a Nav of the fund's views and PageColumns with a rail card (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

Example: The notifications open from the header (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

## Variants
The frame has one look, whose shape follows its width and the person's fold. `AppShellMain` lays out the page in one of two ways.

### layout
- `page`: a page of sections and a rail, centred up to 72rem with the gutter at its sides, scrolling in the main area. Used in `docs/system/examples/sidebar/default.tsx`.
- `fill`: the whole area handed to a layout that scrolls its own parts, such as ListDetail. Used in `docs/system/examples/list-detail/in-shell.tsx`.

Example: A fund's page centred in the main area, scrolling under the header (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| open | the shell 640px wide or more, not folded | read every place's name, open one, fold the sidebar | the 240px column with names, counts and group headings | test |
| folded | the person folds it, or `defaultFolded`, on a shell 640px wide or more | open a place by its glyph, read its name in the tooltip, unfold | the 60px rail of glyphs; a 10px mark on a counted place | test |
| sheet | the trigger pressed on a shell under 640px | choose a place, which closes the sheet; close it with the button, Escape, the scrim or a swipe | a bottom sheet with a grabber, under the menu glyph's "Open navigation" | screenshot |
| current | the place the page belongs to, `current`, or a router link that sets `aria-current` itself | read where they are | `aria-current="page"`, the pill that slides there from the last place, `--thumb` in the column and the grey fill in the sheet, and the ink | test |
| counted | `count` above 0 | read how many need them | a badge with the figure, 99+ past 99; the mark in the rail; the words in the name, "Inbox, 3 unread" | test |
| group-closed | the person closes a collapsible group | open it again from its heading | the heading's chevron turned, the rows gone; in the rail the rows stay gone | test |
| hover | pointer over a row, under `(hover: hover)` | open it | a place: the ink alone, since the pill is the only fill (D43); a menu's trigger: the grey fill and the ink | by hand |
| pressed | pointer or key down on a row | let go to open it | a place: the ink, then the pill slides to it; a menu's trigger: the fill darkens one step; nothing moves | by hand |
| focus-visible | Tab or an arrow onto a row | open it with Enter, move with the arrows | the 2px outline on the row's holder, on its corner | by hand |
| cut | a name wider than 170px | read it whole in the tooltip | an ellipsis at the end of the name | test |

Example: A shell that opens folded, as the person left it, kept under a storage key (`docs/system/examples/sidebar/folded.tsx`)

```tsx
import { useState, type MouseEvent } from "react";

import { BookmarkIcon, FileTextIcon, HomeIcon, LayoutGridIcon, SettingsIcon } from "@/components/cobalt/icon";
import { Item, ItemContent, ItemDescription, ItemGroup, ItemTitle } from "@/components/cobalt/ui/item";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";

const places = [
  { href: "#home", label: "Home", icon: <HomeIcon /> },
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon /> },
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
];

// A few rows for each page, so the folded rail stands beside a page with something on it.
const rows: Record<string, { title: string; about: string }[]> = {
  "#home": [
    { title: "Calder Global Equity filed a 13F", about: "2 hours ago" },
    { title: "Northgate Advisors amended its Form ADV", about: "Yesterday" },
    { title: "Oakline Energy Transition filed a Form PF", about: "3 days ago" },
  ],
  "#funds": [
    { title: "Harbour Street Master Fund", about: "Harbour Street Partners, New York" },
    { title: "Calder Global Equity", about: "Calder Capital, London" },
    { title: "Meridian Credit Opportunities", about: "Meridian Partners, Chicago" },
  ],
  "#filings": [
    { title: "Calder Global Equity", about: "13F for the third quarter" },
    { title: "Northgate Short Duration", about: "Form ADV, amended" },
    { title: "Harbour Street Master Fund", about: "Form PF" },
  ],
  "#watchlist": [
    { title: "Harbour Street Master Fund", about: "Filed a Form PF 9 days ago" },
    { title: "Meridian Credit Opportunities", about: "Filed a Form D 4 days ago" },
  ],
  "#settings": [
    { title: "Account", about: "Name, work email and language" },
    { title: "Notifications", about: "Filing alerts and the weekly digest" },
  ],
};

export default function Example() {
  const [current, setCurrent] = useState("#filings");
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  return (
    <div className="h-96 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        defaultFolded
        storageKey="example-sidebar-folded"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarBody>
              <SidebarGroup>
                {places.map((p) => (
                  <SidebarItem key={p.href} {...p} current={current === p.href} />
                ))}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              <SidebarItem href="#settings" label="Settings" icon={<SettingsIcon />} current={current === "#settings"} />
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger />
        </AppShellHeader>
        <AppShellMain>
          <PageHeader title={places.find((p) => p.href === current)?.label ?? "Settings"} />
          <ItemGroup variant="card" render={<ul aria-label="Recent" />}>
            {(rows[current] ?? []).map((row) => (
              <li key={row.title}>
                <Item>
                  <ItemContent>
                    <ItemTitle>{row.title}</ItemTitle>
                    <ItemDescription>{row.about}</ItemDescription>
                  </ItemContent>
                </Item>
              </li>
            ))}
          </ItemGroup>
        </AppShellMain>
      </AppShell>
    </div>
  );
}
```

Example: Below 640px the header's menu opens the places as a bottom sheet; choosing one closes it (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

Example: Inbox and Filings carry counts, 99+ past 99, and a mark in the rail (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

Example: The Saved group closes to its heading and opens again (`docs/system/examples/sidebar/default.tsx`)

```tsx
import { useState, type MouseEvent, type ReactNode } from "react";

import {
  BellIcon,
  BookmarkIcon,
  FileTextIcon,
  FilterIcon,
  HomeIcon,
  InboxIcon,
  LayoutGridIcon,
  SettingsIcon,
  UsersIcon,
} from "@/components/cobalt/icon";
import { Avatar, AvatarFallback } from "@/components/cobalt/ui/avatar";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@/components/cobalt/ui/dropdown-menu";
import { Inbox, type InboxNotice } from "@/components/cobalt/ui/inbox";
import { ItemIcon } from "@/components/cobalt/ui/item";
import { Nav } from "@/components/cobalt/ui/nav";
import { PageColumns } from "@/components/cobalt/ui/page-columns";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { RailCard } from "@/components/cobalt/ui/rail-card";
import { Section } from "@/components/cobalt/ui/section";
import { ShortcutKeys, ShortcutsDialog } from "@/components/cobalt/ui/shortcuts-dialog";
import {
  AppShell,
  AppShellHeader,
  AppShellMain,
  Sidebar,
  SidebarBody,
  SidebarFooter,
  SidebarGroup,
  SidebarHeader,
  SidebarItem,
  SidebarTrigger,
} from "@/components/cobalt/ui/sidebar";
import type { LinkProps } from "@/lib/cobalt/link";
import { defineShortcuts, useShortcuts } from "@/lib/cobalt/shortcuts";

// Stands in for your API call. It answers after 900ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 900),
  );

// One map of the product's keys: the shell binds them, and the dialog lists the same map.
const shortcuts = defineShortcuts({
  sidebar: { keys: "mod+\\", label: "Collapse or expand the sidebar", group: "General" },
  help: { keys: "?", label: "Show keyboard shortcuts", group: "General" },
  home: { keys: "g h", label: "Go to home", group: "Go to" },
  inbox: { keys: "g i", label: "Go to inbox", group: "Go to" },
  funds: { keys: "g f", label: "Go to funds", group: "Go to" },
});

// A fixed moment, so the times read the same on every visit.
const now = Date.UTC(2026, 9, 16, 15, 0);
const hour = 3_600_000;

const firstNotices: InboxNotice[] = [
  {
    id: "calder-13f",
    text: "Calder Global Equity filed a 13F for the third quarter",
    at: now - 2 * hour,
    read: false,
    href: "#calder-13f",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
  {
    id: "amara-mention",
    text: "Amara Okafor mentioned you in Private credit over $1 billion",
    at: now - 5 * hour,
    read: false,
    href: "#amara-mention",
    media: (
      <Avatar decorative>
        <AvatarFallback>AO</AvatarFallback>
      </Avatar>
    ),
  },
  {
    id: "northgate-adv",
    text: "Northgate Advisors amended its Form ADV",
    at: now - 26 * hour,
    read: true,
    href: "#northgate-adv",
    media: (
      <ItemIcon>
        <FileTextIcon />
      </ItemIcon>
    ),
  },
];

const research = [
  { href: "#funds", label: "Funds", icon: <LayoutGridIcon /> },
  { href: "#advisers", label: "Advisers", icon: <UsersIcon /> },
  { href: "#filings", label: "Filings", icon: <FileTextIcon />, count: 128, countLabel: "128 new" },
];
const saved = [
  { href: "#watchlist", label: "Watchlist", icon: <BookmarkIcon /> },
  { href: "#searches", label: "Saved searches", icon: <FilterIcon /> },
  { href: "#alerts", label: "Filing alerts", icon: <BellIcon /> },
];

const holdings = [
  { name: "Calder Global Equity", share: "12.4%" },
  { name: "Northgate Short Duration", share: "9.8%" },
  { name: "Oakline Energy", share: "7.1%" },
];

export default function Example() {
  const [current, setCurrent] = useState("#funds");
  const [notices, setNotices] = useState(firstNotices);
  const [keysOpen, setKeysOpen] = useState(false);
  const unread = notices.filter((n) => !n.read).length;
  useShortcuts(shortcuts, {
    home: () => setCurrent("#home"),
    inbox: () => setCurrent("#inbox"),
    funds: () => setCurrent("#funds"),
  });
  // A router would own the links; here a press only changes which place is current.
  const renderLink = ({ href, children, ...props }: LinkProps & { onClick?: () => void }) => (
    <a
      href={href}
      {...props}
      onClick={(event: MouseEvent) => {
        event.preventDefault();
        props.onClick?.();
        setCurrent(href);
      }}
    >
      {children}
    </a>
  );
  const place = (p: { href: string; label: string; icon: ReactNode; count?: number; countLabel?: string }) => (
    <SidebarItem key={p.href} {...p} current={current === p.href} />
  );
  return (
    <div className="h-160 w-full overflow-hidden rounded-2xl ring-1 ring-border">
      <AppShell
        className="h-full"
        renderLink={renderLink}
        sidebar={
          <Sidebar label="Main">
            <SidebarHeader>
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Northwind Research"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>N</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent>
                  <DropdownMenuItem>Northwind Research</DropdownMenuItem>
                  <DropdownMenuItem>Calder Partners</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarHeader>
            <SidebarBody>
              <SidebarGroup>
                {place({ href: "#home", label: "Home", icon: <HomeIcon /> })}
                {place({
                  href: "#inbox",
                  label: "Inbox",
                  icon: <InboxIcon />,
                  count: unread,
                  countLabel: `${unread} unread`,
                })}
              </SidebarGroup>
              <SidebarGroup label="Research">{research.map(place)}</SidebarGroup>
              <SidebarGroup label="Saved" collapsible>
                {saved.map(place)}
              </SidebarGroup>
            </SidebarBody>
            <SidebarFooter>
              {place({ href: "#settings", label: "Settings", icon: <SettingsIcon /> })}
              <DropdownMenu>
                <DropdownMenuTrigger
                  render={
                    <SidebarItem
                      label="Priya Raman"
                      icon={
                        <Avatar size="sm" decorative>
                          <AvatarFallback>PR</AvatarFallback>
                        </Avatar>
                      }
                    />
                  }
                />
                <DropdownMenuContent side="top">
                  <DropdownMenuItem>Profile</DropdownMenuItem>
                  <DropdownMenuItem onClick={() => setKeysOpen(true)}>
                    Keyboard shortcuts
                    <ShortcutKeys keys={shortcuts.help.keys} className="ms-auto" />
                  </DropdownMenuItem>
                  <DropdownMenuItem>Sign out</DropdownMenuItem>
                </DropdownMenuContent>
              </DropdownMenu>
            </SidebarFooter>
          </Sidebar>
        }
      >
        <AppShellHeader>
          <SidebarTrigger shortcut={shortcuts.sidebar.keys} />
          <span className="flex-1" />
          <Inbox
            notices={notices}
            now={now}
            onOpenNotice={(opened) =>
              setNotices((was) => was.map((n) => (n.id === opened.id ? { ...n, read: true } : n)))
            }
            onMarkAllRead={async () => {
              await request();
              setNotices((was) => was.map((n) => ({ ...n, read: true })));
            }}
          />
        </AppShellHeader>
        <AppShellMain>
          <div className="flex flex-col gap-4">
            <PageHeader eyebrow="Fund" title="Harbour Street Master Fund" description="Advised by Harbour Street Partners, New York" />
            <Nav
              label="Fund"
              activeKey="overview"
              items={[
                { key: "overview", label: "Overview", href: "#overview" },
                { key: "holdings", label: "Holdings", href: "#holdings" },
                { key: "filings", label: "Filings", href: "#fund-filings" },
              ]}
            />
          </div>
          <PageColumns
            rail={
              <RailCard id="example-shell-facts" heading="Gross assets">
                <p className="text-2xl font-semibold tracking-tight tabular-nums">$48.2B</p>
              </RailCard>
            }
          >
            <Section id="example-shell-holdings" heading="Largest holdings">
              <ul className="flex flex-col gap-2 text-sm">
                {holdings.map((h) => (
                  <li key={h.name} className="flex justify-between gap-4">
                    <span>{h.name}</span>
                    <span className="text-muted-foreground tabular-nums">{h.share}</span>
                  </li>
                ))}
              </ul>
            </Section>
          </PageColumns>
        </AppShellMain>
      </AppShell>
      <ShortcutsDialog shortcuts={shortcuts} open={keysOpen} onOpenChange={setKeysOpen} />
    </div>
  );
}
```

### State precedence
- Open and folded: Not applicable: the fold is one value.
- Folded and sheet: the sheet wins below 640px, with every name; the person's fold is kept and comes back at 640px.
- Current and hover: current wins. The pill stays under the pointer (D9).
- Current and group-closed: group-closed wins. The pill is cut with its row as the group closes, and comes back with it when the group opens.
- Counted and folded: both show. The badge fades with the name and the mark shows at the glyph's corner.
- Group-closed and folded: group-closed wins. The rows stay hidden in the rail; unfolding the sidebar, or the sheet, opens them.
- Focus-visible and current or hover: both show. The outline is drawn outside the fill.
- Cut and folded: folded wins. The tooltip names the place in either state.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| the person unfolds the sidebar | input | `--t-layout` on `--curve-layout` (Grow) | the column's and each row holder's width; the names, counts and headings fade in on `--t-fade` | the width changes at once; the names show at once |
| the person folds the sidebar | input | `--t-settle` on `--curve-settle` | the same widths; the names fade out on `--t-fade` | the width changes at once |
| the sheet opens and closes | input | `--t-sheet` on `--curve-sheet`, out on `--t-leave` (Sheet's Slide) | translate, the scrim's opacity | a short fade (Sheet) |
| a group opens and closes | input | `--t-layout` on `--curve-layout`, closing on `--t-settle` (Collapsible) | height, opacity, the chevron's rotation | no transition |
| another place becomes current, in the same region | announce | `duration-settle ease-settle` (`--t-settle`, 300ms, on `--curve-settle`), through `useIndicator`, the travel of the nav's pill; the label's ink on the same spring, so it lands as the pill does; not on first paint, a resize, a font swap or a group opening | transform (translateY) and height of the pill, color of the label | the pill jumps to the place; the colour change stays |
| a place in another region becomes current, such as Settings in the foot | announce | the same spring; the body's pill slides out of the body's edge as the foot's slides in from it, frame for frame | transform of both pills, each clipped by its region | the pill jumps |
| a group opens or closes above or around the current place | announce | none of its own: the pill follows its row in every frame (`ResizeObserver`, applied before paint) and is cut where the group cuts the row | transform and clip-path of the pill | the same |
| pointer over and out, and press, on a place | input | the ink on `--t-settle` | color | the same colour change |
| pointer over and out, and press, on a menu's trigger | input | `pressable`, `--t-press` on `--curve` | background-color, color, box-shadow | the same colour change; nothing moves |

Measured at 1440 (`.design-system/evidence/sidebar/fold-1440.json`): the column goes 240, 158, 94, 75, 64, 61, 60px at 40ms steps folding and 60, 87, 152, 184, 214, 229, 240px unfolding, and every glyph, name and badge holds the same place in the column in every frame.

The pill, sampled every frame at 1440 (`.design-system/evidence/sidebar/pill-1440.json`). Before, the white fill appeared on the new row in place, fading in over 140ms, with nothing travelling. After: Advisers to Watchlist, the pill's top goes 224, 236, 257, 279, 298, 313, 323, 331, 336, 339, 342, 343, 344, 345, 345, 346px a frame apart, and the label's ink reaches the same share of its change in the same frame; Watchlist to Settings in the foot, the body's pill and the foot's stand at 346, 366, 403, 440, 472, 497, 515, 528, 536, 542, 546, 549, 551, 552, 553, 553, 554px a frame apart, together, and the body's hides once there; closing Saved with Saved searches current, the pill is cut by 0, 13, 30, then 36px of its 36px with its row; folding, its width goes 216, 167, 85, 51, 40, 37, 36px at 50ms steps with the holders'.

## Props

<!-- Props generated from registry/cobalt/ui/sidebar.tsx with TypeScript by scripts/props-table.mjs -->
### Sidebar

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `children` | `ReactNode` |  |  |
| `className?` | `string` |  |  |
| `closeLabel?` | `string` | `"Close navigation"` | The name of the sheet's close button. |
| `label?` | `string` | `"Main"` | The navigation's accessible name, also the sheet's title for a screen reader. |

### AppShell

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `children` | `ReactNode` |  | `AppShellHeader` and `AppShellMain`. |
| `sidebar` | `ReactNode` |  | The `Sidebar`. |
| `className?` | `string` |  |  |
| `defaultFolded?` | `boolean` | `false` | Folded on the first visit. |
| `folded?` | `boolean` |  | Folded to the rail on a wide shell, controlled. |
| `onFoldedChange?` | `(folded: boolean) => void` |  |  |
| `renderLink?` | `RenderLink` | `defaultLink` | Swaps the sidebar's anchors for a router's links. |
| `storageKey?` | `string` |  | Keeps the fold in the browser under this key, so the next visit opens the way the person left it. |

### AppShellHeader

No props of its own.

Also accepts every native HTML attribute.

### AppShellMain

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `layout?` | `"page" \| "fill"` | `"page"` | `page` a page of sections and a rail; `fill` the whole area handed to a layout that scrolls its own parts. |

Also accepts every native HTML attribute.

### SidebarHeader

No props of its own.

Also accepts every native `<div>` attribute.

### SidebarBody

No props of its own.

Also accepts every native HTML attribute.

### SidebarFooter

No props of its own.

Also accepts every native `<div>` attribute.

### SidebarGroup

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `children` | `ReactNode` |  | The group's `SidebarItem`s. |
| `className?` | `string` |  |  |
| `collapsible?` | `boolean` | `false` |  |
| `defaultOpen?` | `boolean` | `true` |  |
| `label?` | `string` |  | The heading. |
| `onOpenChange?` | `(open: boolean) => void` |  |  |
| `open?` | `boolean` |  |  |

### SidebarItem

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `label` | `string` |  |  |
| `count?` | `number` |  |  |
| `countLabel?` | `string` |  |  |
| `current?` | `boolean` | `false` |  |
| `href?` | `string` |  | Where it goes. |
| `icon?` | `ReactNode` |  | The glyph, from the icon barrel, or an `Avatar` at `size="sm"`. |
| `renderLink?` | `RenderLink` |  |  |

Also accepts every native `<button>` attribute.

### SidebarTrigger

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `className?` | `string` |  |  |
| `labels?` | `{ fold?: string; unfold?: string; open?: string; }` | `{}` |  |
| `shortcut?` | `string` |  | Keys that do the same, in the shortcut map's form. |

`AppShell` takes `sidebar` (the `Sidebar`) and its children, `AppShellHeader` and `AppShellMain`; `folded`, `defaultFolded` and `onFoldedChange` for the fold, and `storageKey` to keep it in the browser; `renderLink` for every place. `Sidebar` takes `label`, the navigation's name and the sheet's title, and `closeLabel`. `SidebarGroup` takes `label`, `collapsible`, `defaultOpen`, `open` and `onOpenChange`. `SidebarItem` takes `label`, `icon`, `href` (a link; without it a button, such as a menu's trigger), `current`, `count`, `countLabel` and `renderLink`, and passes a button's own attributes through. `SidebarTrigger` takes `shortcut` and `labels` (`fold`, `unfold`, `open`). `AppShellMain` takes `layout`. `useSidebar` returns the fold, the mode the width allows, the sheet's state and `toggle`, for a control of your own.

## Usage

### When to use
- A product with five or more places, or places in groups: a research tool, a dashboard, an admin area.
- A product people keep open all day, where folding the side to glyphs gives the page its room.

### When not to use
- Two to five places and no groups. Use Nav instead, across the top, with NavTabs on a phone.
- The sections of one settings page. Use SettingsLayout instead.
- The views of one record. Use Tabs instead.

### Rules
- `rule/sidebar-places-are-links`: When adding a place, pass `href` to `SidebarItem` and route through `renderLink`, instead of `onClick` that swaps the page, because a place with an address opens in a new tab, works with Back and can be shared. Evidence: principle platform: the address is the state a person can share and go back to; person D5. Check: test `sidebar.test.tsx` finds every place an `a` with its `href`.
  - Don't: `<SidebarItem label="Funds" onClick={() => setPage("funds")} />`
  - Do: `<SidebarItem href="/funds" label="Funds" icon={<LayoutGridIcon />} current={path === "/funds"} />`
- `rule/sidebar-count-in-words`: When a place carries a `count`, pass `countLabel` with the noun, such as "12 unread", instead of the bare figure, because the badge is hidden from a screen reader and the name is the only place the count is read. Evidence: principle wcag: 1.1.1 non-text content; single use docs/system/examples/sidebar/default.tsx:188. Check: test `sidebar.test.tsx` reads "Inbox, 128 unread" as the name.
  - Don't: `<SidebarItem href="/inbox" label="Inbox" count={12} />`
  - Do: `<SidebarItem href="/inbox" label="Inbox" count={12} countLabel="12 unread" />`
- `rule/sidebar-fold-kept`: When the product has accounts, pass `storageKey`, or `folded` and `onFoldedChange` saved with the account, instead of a fold that resets on every visit, because a person who folds the sidebar to a rail wants it folded tomorrow. Evidence: principle heuristic: user control and freedom; single use docs/system/examples/sidebar/folded.tsx:76. Check: review.
  - Don't: `<AppShell sidebar={sidebar}>`
  - Do: `<AppShell storageKey="research-sidebar" sidebar={sidebar}>`
- `rule/sidebar-one-trigger`: When placing the fold control, render one `SidebarTrigger` at the start of `AppShellHeader`, instead of a second control inside the sidebar, because the one control folds the column, opens the sheet below 640px and is in the same place in both. Evidence: principle heuristic: consistency and standards, one control for one job; person D14. Check: review.
  - Don't: `<SidebarHeader><Button onClick={toggle}>Collapse</Button></SidebarHeader>`
  - Do: `<AppShellHeader><SidebarTrigger shortcut="mod+\" /></AppShellHeader>`

### Content
- `rule/sidebar-label-noun`: When naming a place, write the noun of what it holds, such as "Filings" or "Saved searches", in at most 23 characters, instead of a verb or a sentence, because the name is read hundreds of times a day and the 170px row cuts a longer one. Evidence: measured 170px of room for a name at 7.39px a character of `text-sm`, `.design-system/evidence/sidebar/fold-1440.json`. Check: review.
  - Don't: `<SidebarItem label="Browse all the funds we track" />`
  - Do: `<SidebarItem label="Funds" />`

### Anti-slop
- `rule/sidebar-no-dots`: When a place needs the person, pass `count` with a number, instead of a dot beside its name, because a dot says something happened without saying how much, and the system draws no dot that carries no figure. Evidence: person D46; principle heuristic: visibility of system status, a figure says how much. Check: review.
  - Don't: `<SidebarItem label="Inbox" icon={<InboxIcon />} /><span className="size-2 rounded-full bg-primary" />`
  - Do: `<SidebarItem label="Inbox" icon={<InboxIcon />} count={3} countLabel="3 unread" />`

### Limits
- `rule/sidebar-label-room`: When a name runs past 23 characters, shorten it, instead of relying on the ellipsis, because the row has 170px for the name and cuts the rest, which the person then reads only in the tooltip. Evidence: measured 170px of room and 7.39px a character, "Saved searches" 103.5px wide, `.design-system/evidence/sidebar/fold-1440.json`. Check: probe docs/system/stress/sidebar.tsx with the worst case at 1440.
  - Don't: `label="Einreichungen bei der Aufsichtsbehörde"`
  - Do: `label="Einreichungen"`

## Accessibility
Rests on a `nav` named by the sidebar's `label`, `ul` lists of links, Base UI's Collapsible for a group, the Sheet's dialog below 640px and IconButton for the trigger.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | anywhere in the shell | moves through the workspace menu, the places, the account menu, then the header and the page | the next control | by hand |
| Down arrow, Up arrow | a place or a group's heading | moves to the next or the last row, stopping at the ends | that row | by hand |
| Home, End | a place or a group's heading | moves to the first or the last row | that row | by hand |
| Enter | a place | opens it; in the sheet the sheet closes | the host's focus after a route change | by hand |
| Enter, Space | a group's heading | closes or opens the group | the heading | by hand |
| Enter, Space | the trigger | folds or unfolds from 640px, opens the sheet on a phone | the trigger, or the sheet's first control | by hand |
| the trigger's `shortcut`, such as Command or Control and backslash | anywhere outside a field and an open dialog | the same as pressing the trigger | where it was | by hand |
| Escape | inside the sheet | closes the sheet | the trigger | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| SidebarBody | navigation | `label` | none | "Main, navigation" | test |
| SidebarItem with `href` | link | its `label`, with the count in words when counted | `aria-current="page"` when current | "Inbox, 3 unread, link" | test |
| SidebarItem without `href` | button | its `label` | the menu's `aria-expanded` and `aria-haspopup` when it is a trigger | "Priya Raman, button, collapsed" | by hand |
| SidebarGroup heading, collapsible | button | its `label` | `aria-expanded`, `aria-controls`; `inert` in the rail | "Saved, button, expanded" | test |
| SidebarGroup rows | group | the heading through `aria-labelledby` | none | "Saved, group" | test |
| badge and rail mark | none, `aria-hidden` | none | none | nothing; the name carries the count | test |
| SidebarTrigger | button | "Collapse sidebar", "Expand sidebar" or "Open navigation" | `aria-keyshortcuts` when it has a shortcut | "Collapse sidebar, button" | test |
| sheet | dialog | the sidebar's `label`, a visually hidden title | modal | "Main, dialog" | by hand |

## Tokens
| Part | State | Token |
|---|---|---|
| shell, column, header | all | `--background`, `--foreground`, `--gutter` |
| row | all | `--control`, `--r-control`, `--muted-foreground` |
| pill in the column | current | `--thumb`, `--r-control`, `--t-settle`, `--curve-settle` |
| pill in the sheet | current | `--muted`, `--r-control`, `--t-settle`, `--curve-settle` |
| place | current, hover, pressed | `--foreground`, `--t-settle`, `--curve-settle` |
| menu's trigger | hover, pressed | `--muted`, `--hover`, `--t-press`, `--curve` |
| row holder | focus-visible | `--ring`, `--line-focus`, `--focus-offset` |
| count | all | `--primary`, `--primary-foreground`, `--r-tag` |
| rail mark | all | `--primary`, `--r-xs` |
| column and row holders | folding | `--t-layout`, `--curve-layout`, `--t-settle`, `--curve-settle`, `--t-fade` |
| row in the sheet | coarse pointer | `--touch` |

## Related
- Nav: the places across the top when there are few of them.
- SettingsLayout: the sections of a settings page.
- Sheet: the panel the sidebar opens as below 640px.
- PageHeader and PageColumns: the page inside `AppShellMain`.
- Inbox: the notifications in the header.
- Keyboard shortcuts: the map the trigger's shortcut comes from.
