Skip to content
Thrum

App shell

A complete SaaS application frame combining a collapsible left sidebar, workspace switcher, grouped navigation, user footer, top bar with breadcrumbs and search trigger, and a scrolling content canvas. It adapts to its own container width, folding the sidebar into a slide-over drawer below 576 pixels. Use the sidebar alone when you already have your own page chrome.

Install

npx shadcn@latest add https://thrumui.dev/r/app-shell.json

Adds components/app-shell.tsx and installs motion. Nothing else in your project changes.

import { AppShell } from "@/components/app-shell";

Automatically installs icons chevrons-up-down, menu, panel-left, search and x from the icon set.

Data shape

Type
type AppShellNavItem = {
  id: string;
  label: string;
  href?: string;
  icon?: ReactNode;
  badge?: string | number;
  disabled?: boolean;
};
type AppShellNavGroup = { label?: string; items: readonly AppShellNavItem[] };
Sample
const groups: AppShellNavGroup[] = [
  {
    label: "Workspace",
    items: [
      { id: "overview", label: "Overview", icon: <HomeIcon size={16} /> },
      { id: "analytics", label: "Analytics", icon: <ChartColumnIcon size={16} />, badge: "Live" },
    ],
  },
];

Props

PropTypeDefaultDescription
workspaceAppShellWorkspaceRequiredWorkspace name, optional plan subtitle and 28 px mark shown in the sidebar header.
onWorkspaceClick() => void–Turns the workspace header into a switcher button with a chevron mark.
groupsreadonly AppShellNavGroup[]RequiredLabelled sections of navigation items rendered in the sidebar and mobile drawer.
activeIdstring–Active destination id, when controlled by the parent. Use with onActiveChange.
defaultActiveIdstring–Starting destination id, when uncontrolled. Defaults to the first navigation item.
onActiveChange(id: string, item: AppShellNavItem) => void–Called when the reader selects a navigation item.
collapsedboolean–Whether the desktop sidebar is folded into a 52 px icon rail, when controlled.
defaultCollapsedbooleanDefault falseWhether the desktop sidebar starts collapsed, when uncontrolled.
onCollapsedChange(collapsed: boolean) => void–Called whenever the desktop sidebar collapses or expands.
collapseShortcutstring | falseDefault "["Single key that toggles the desktop sidebar when focus is outside text inputs. Pass false to turn it off.
breadcrumbsreadonly BreadcrumbEntry[]–Trail shown in the top bar. Defaults to the workspace name and active item label.
showSearchbooleanDefault trueShow the search trigger button with its shortcut pill in the top bar.
searchLabelstringDefault "Search"Label printed on the search button and announced by screen readers.
searchShortcutstringDefault "mod+k"Shortcut string rendered as key caps inside the search button.
onSearch() => void–Called when the search trigger button is pressed. Wire it to your command palette.
actionsReactNode–Optional buttons or controls placed at the end of the top bar.
userAppShellUser–Account summary with Avatar rendered in the sidebar footer when footer is not provided.
footerReactNode–Custom sidebar footer content. Replaces the default user row.
compactbooleanDefault falseReduces sidebar width, row height, top bar height and canvas padding.
navLabelstringDefault "Workspace navigation"Accessible label applied to the navigation landmark and mobile drawer.
contentAs"div" | "main"Default "div"Element used for the content canvas. Set to "main" in a full-page application.
soundbooleanDefault truePlay selection, toggle and drawer sounds when the visitor has sound on.
classNamestring–Merged onto the outer shell frame. Set a height such as h-dvh or h-[440px] so the canvas scrolls inside.

Motion and sound

Motion

  • The desktop sidebar transitions its width between 224 px (192 px when compact) and 52 px over 200 ms.
  • The active navigation pill glides to the newly selected item with the control spring.
  • On narrow containers below 576 px, the mobile drawer slides in over 250 ms and its scrim fades over 150 ms.
  • Reduced motion: width changes, active indicator moves and drawer openings settle on the first frame.

Sound

  • Switching navigation items plays select.
  • Expanding the sidebar plays toggleOn; collapsing to the rail plays toggleOff.
  • Opening the search trigger or mobile drawer plays open; closing the mobile drawer plays close.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • The desktop sidebar is an aside containing a named nav landmark; active items carry aria-current="page", a fill, heavier weight and a 2 px primary bar so selection never relies on colour alone.
  • The collapse button exposes aria-expanded, aria-controls and aria-keyshortcuts; in rail mode, item labels remain in the accessibility tree and native tooltips expose each destination name.
  • Below 576 px container width, the menu button opens a modal drawer dialog and returns focus to the button on close or Escape.
  • The outer frame carries data-surface="panel" once, with no nested glass panes inside it, preserving 4.5:1 contrast across Solid and Frosted glass materials.
KeysAction
[Toggle the desktop sidebar between full width and the 52 px icon rail.
Tab / Shift TabMove through the workspace header, navigation items, collapse toggle, breadcrumbs, search trigger and top bar actions.
Enter / SpaceActivate the focused navigation item, sidebar toggle or search button.
EscClose the mobile navigation drawer and return focus to the menu button.

Source

components/app-shell.tsx
"use client";

import { useEffect, useId, useRef, useState, type ComponentProps, type ReactNode } from "react";
import { AnimatePresence, motion } from "motion/react";

import { cn } from "@/lib/utils";
import { ChevronsUpDownIcon } from "@/components/icons/chevrons-up-down";
import { MenuIcon } from "@/components/icons/menu";
import { PanelLeftIcon } from "@/components/icons/panel-left";
import { SearchIcon } from "@/components/icons/search";
import { XIcon } from "@/components/icons/x";
import { ENTER, FAST, INSTANT, SPRING, useReducedMotion } from "@/lib/thrum-motion";
import { play } from "@/lib/thrum-sound";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Breadcrumb, type BreadcrumbEntry } from "@/components/ui/breadcrumb";
import { Shortcut } from "@/components/ui/kbd";

export type AppShellNavItem = {
  /** Unique identifier for this destination. */
  id: string;
  /** Visible label in the sidebar and mobile drawer. */
  label: string;
  /** Optional link URL. With `href` the item renders as a link; without it, as a button. */
  href?: string;
  /** Optional 16 px icon drawn beside the label, and shown alone in the collapsed rail. */
  icon?: ReactNode;
  /** Optional count or short badge printed at the end of the row. */
  badge?: string | number;
  /** Prevents selection and dims the row. */
  disabled?: boolean;
};

export type AppShellNavGroup = {
  /** Optional heading above the group's items. Visually hidden in the collapsed rail. */
  label?: string;
  /** Destinations inside this group. */
  items: readonly AppShellNavItem[];
};

export type AppShellWorkspace = {
  /** Workspace or organisation name shown at the top of the sidebar. */
  name: string;
  /** Optional secondary line under the name, such as the current plan or environment. */
  plan?: string;
  /** Optional 28 px mark shown before the name; defaults to the first letter of `name`. */
  mark?: ReactNode;
};

export type AppShellUser = {
  /** Full name shown in the sidebar footer and used for avatar initials. */
  name: string;
  /** Optional secondary detail such as an email address or role. */
  detail?: string;
  /** Optional portrait image URL. */
  avatar?: string;
};

export type AppShellProps = Omit<ComponentProps<"div">, "children"> & {
  /** Workspace identity shown in the sidebar header. */
  workspace: AppShellWorkspace;
  /** Called when the workspace header button is pressed; turns the header into an interactive switcher trigger. */
  onWorkspaceClick?: () => void;
  /** Grouped navigation destinations shown in the sidebar and mobile drawer. */
  groups: readonly AppShellNavGroup[];
  /** Currently active navigation item id, when controlled by the parent. */
  activeId?: string;
  /** Initial active navigation item id, when uncontrolled. Defaults to the first item. */
  defaultActiveId?: string;
  /** Called when the reader picks a navigation item. */
  onActiveChange?: (id: string, item: AppShellNavItem) => void;
  /** Whether the desktop sidebar is collapsed to a 52 px icon rail, when controlled. */
  collapsed?: boolean;
  /** Whether the desktop sidebar starts collapsed to an icon rail, when uncontrolled. */
  defaultCollapsed?: boolean;
  /** Called whenever the desktop sidebar collapses or expands. */
  onCollapsedChange?: (collapsed: boolean) => void;
  /** Single key that toggles the desktop sidebar when no text field is focused. Pass `false` to disable. */
  collapseShortcut?: string | false;
  /** Breadcrumb trail in the top bar. Defaults to `[workspace.name, activeItem.label]`. */
  breadcrumbs?: readonly BreadcrumbEntry[];
  /** Show the search button in the top bar. */
  showSearch?: boolean;
  /** Label printed on the search trigger button. */
  searchLabel?: string;
  /** Shortcut pill printed inside the search trigger button. */
  searchShortcut?: string;
  /** Called when the search trigger button is pressed. */
  onSearch?: () => void;
  /** Optional action buttons placed at the end of the top bar. */
  actions?: ReactNode;
  /** User summary shown in the sidebar footer when `footer` is not supplied. */
  user?: AppShellUser;
  /** Custom sidebar footer content. Replaces the default `user` row when provided. */
  footer?: ReactNode;
  /** Tighter spacing across the sidebar, top bar and content canvas. */
  compact?: boolean;
  /** Accessible name for the navigation landmark. */
  navLabel?: string;
  /** HTML element for the main content canvas. Use `"main"` on a full-page layout; defaults to `"div"` so embedded previews keep one `<main>`. */
  contentAs?: "div" | "main";
  /** Play subtle selection and toggle sounds, if the visitor has sound on. */
  sound?: boolean;
  /** Main page content rendered inside the scrollable canvas. */
  children?: ReactNode;
};

const FOCUS = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";

function firstNavItem(groups: readonly AppShellNavGroup[]): AppShellNavItem | undefined {
  for (const group of groups) {
    if (group.items.length > 0) return group.items[0];
  }
  return undefined;
}

function findNavItem(groups: readonly AppShellNavGroup[], id: string | undefined): AppShellNavItem | undefined {
  if (!id) return undefined;
  for (const group of groups) {
    const match = group.items.find((item) => item.id === id);
    if (match) return match;
  }
  return undefined;
}

/**
 * A complete SaaS application frame: collapsible left sidebar with workspace switcher, grouped navigation
 * and footer user slot, container-responsive mobile drawer, top bar with breadcrumbs, search trigger and
 * actions, and a scrolling main content canvas.
 */
export function AppShell({
  workspace,
  onWorkspaceClick,
  groups,
  activeId,
  defaultActiveId,
  onActiveChange,
  collapsed,
  defaultCollapsed = false,
  onCollapsedChange,
  collapseShortcut = "[",
  breadcrumbs,
  showSearch = true,
  searchLabel = "Search",
  searchShortcut = "mod+k",
  onSearch,
  actions,
  user,
  footer,
  compact = false,
  navLabel = "Workspace navigation",
  contentAs = "div",
  sound = true,
  className,
  children,
  ...props
}: AppShellProps) {
  const reduced = useReducedMotion();
  const sidebarId = useId();
  const drawerId = useId();
  const indicatorId = useId();
  const mobileToggleRef = useRef<HTMLButtonElement>(null);
  const mobileCloseRef = useRef<HTMLButtonElement>(null);

  const [innerActive, setInnerActive] = useState(() => defaultActiveId ?? firstNavItem(groups)?.id ?? "");
  const [innerCollapsed, setInnerCollapsed] = useState(defaultCollapsed);
  const [mobileOpen, setMobileOpen] = useState(false);

  const currentId = activeId ?? innerActive;
  const isCollapsed = collapsed ?? innerCollapsed;
  const activeItem = findNavItem(groups, currentId) ?? firstNavItem(groups);

  const resolvedBreadcrumbs: readonly BreadcrumbEntry[] = breadcrumbs ?? [
    { label: workspace.name },
    ...(activeItem ? [{ label: activeItem.label }] : []),
  ];

  const toggleCollapsed = () => {
    const next = !isCollapsed;
    setInnerCollapsed(next);
    onCollapsedChange?.(next);
    if (sound) play(next ? "toggleOff" : "toggleOn");
  };

  const setDrawer = (next: boolean) => {
    setMobileOpen(next);
    if (sound) play(next ? "open" : "close");
  };

  const selectItem = (item: AppShellNavItem, fromDrawer: boolean) => {
    if (item.disabled) return;
    if (item.id !== currentId) {
      setInnerActive(item.id);
      if (sound) play("select");
    }
    onActiveChange?.(item.id, item);
    if (fromDrawer) {
      setMobileOpen(false);
      mobileToggleRef.current?.focus();
    }
  };

  // Keyboard toggle for the desktop sidebar (`[` by default).
  useEffect(() => {
    if (!collapseShortcut) return;
    const onKeyDown = (event: KeyboardEvent) => {
      if (event.key !== collapseShortcut || event.ctrlKey || event.metaKey || event.altKey || event.repeat) return;
      const target = event.target;
      const typing = target instanceof HTMLElement && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName));
      if (typing) return;
      event.preventDefault();
      toggleCollapsed();
    };
    window.addEventListener("keydown", onKeyDown);
    return () => window.removeEventListener("keydown", onKeyDown);
  });

  // Escape closes the mobile drawer and returns focus to its trigger.
  useEffect(() => {
    if (!mobileOpen) return;
    mobileCloseRef.current?.focus();
    const onKeyDown = (event: KeyboardEvent) => {
      if (event.key !== "Escape") return;
      event.preventDefault();
      setMobileOpen(false);
      if (sound) play("close");
      mobileToggleRef.current?.focus();
    };
    window.addEventListener("keydown", onKeyDown);
    return () => window.removeEventListener("keydown", onKeyDown);
  }, [mobileOpen, sound]);

  const workspaceMark = (
    <span
      aria-hidden="true"
      className="grid size-7 flex-none place-items-center rounded-md bg-primary font-mono text-xs font-semibold text-primary-foreground"
    >
      {workspace.mark ?? workspace.name.slice(0, 1).toUpperCase()}
    </span>
  );

  const renderWorkspaceHeader = (rail: boolean) => {
    const inner = (
      <>
        {workspaceMark}
        {!rail && (
          <span className="grid min-w-0 flex-1 text-start leading-tight">
            <span className="truncate text-sm font-semibold text-foreground">{workspace.name}</span>
            {workspace.plan && <span className="truncate text-xs text-muted-foreground">{workspace.plan}</span>}
          </span>
        )}
        {!rail && onWorkspaceClick && <ChevronsUpDownIcon size={14} className="flex-none text-muted-foreground" />}
      </>
    );

    if (onWorkspaceClick) {
      return (
        <button
          type="button"
          data-slot="app-shell-workspace"
          title={rail ? workspace.name : undefined}
          aria-label={rail ? `Switch workspace: ${workspace.name}` : undefined}
          onClick={() => {
            if (sound) play("select");
            onWorkspaceClick();
          }}
          className={cn(
            "flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 rounded-md px-1.5 py-1 transition-[background-color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground motion-reduce:transition-none",
            rail && "flex-none justify-center p-1",
            FOCUS,
          )}
        >
          {inner}
        </button>
      );
    }

    return (
      <div data-slot="app-shell-workspace" title={rail ? workspace.name : undefined} className={cn("flex min-w-0 flex-1 items-center gap-2.5 px-1.5 py-1", rail && "flex-none justify-center p-1")}>
        {inner}
      </div>
    );
  };

  const renderNavGroups = (rail: boolean, fromDrawer: boolean) => (
    <div className={cn("flex flex-col", compact ? "gap-3" : "gap-4")}>
      {groups.map((group, groupIndex) => (
        <div key={group.label ?? groupIndex} data-slot="app-shell-group" role="group" aria-label={group.label}>
          {group.label && (
            <div className={cn("mb-1 px-2 text-[0.6875rem] font-medium tracking-wider text-muted-foreground uppercase", rail && "sr-only")}>
              <span className="block truncate">{group.label}</span>
            </div>
          )}
          {rail && groupIndex > 0 && <div aria-hidden="true" className="mx-1.5 mb-2 border-t border-border/70" />}
          <ul className="flex flex-col gap-0.5">
            {group.items.map((item) => {
              const active = item.id === currentId;
              const mark = item.icon ?? (rail ? <span className="font-mono text-xs">{item.label.slice(0, 1)}</span> : null);
              const sharedClass = cn(
                "group/nav-item relative flex w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md px-2 text-sm whitespace-nowrap text-muted-foreground",
                compact ? "h-7 text-[0.8125rem]" : "h-8",
                "transition-[background-color,color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground motion-reduce:transition-none",
                "disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
                active && "bg-accent font-medium text-accent-foreground",
                rail && "justify-center px-0",
                FOCUS,
              );
              const content = (
                <>
                  {active &&
                    (fromDrawer ? (
                      <span
                        aria-hidden="true"
                        className="absolute inset-y-1.5 start-0 w-0.5 rounded-[calc(var(--radius)*9999)] bg-primary"
                      />
                    ) : (
                      <motion.span
                        layoutId={indicatorId}
                        aria-hidden="true"
                        transition={reduced ? INSTANT : SPRING.control}
                        className="absolute inset-y-1.5 start-0 w-0.5 rounded-[calc(var(--radius)*9999)] bg-primary"
                      />
                    ))}
                  {mark != null && (
                    <span
                      aria-hidden="true"
                      className={cn(
                        "grid size-4 flex-none place-items-center [&>svg]:size-4",
                        active ? "text-foreground" : "text-muted-foreground group-hover/nav-item:text-accent-foreground",
                      )}
                    >
                      {mark}
                    </span>
                  )}
                  <span className={cn("min-w-0 flex-1 truncate text-start", rail && "sr-only")}>{item.label}</span>
                  {item.badge !== undefined && (
                    <span
                      data-slot="app-shell-nav-badge"
                      className={cn(
                        "flex-none rounded-[calc(var(--radius)*9999)] border border-border/80 bg-background/70 px-1.5 py-0.5 font-mono text-[0.6875rem] leading-none font-medium text-muted-foreground tabular-nums",
                        active && "border-foreground/20 text-foreground",
                        rail && "sr-only",
                      )}
                    >
                      {item.badge}
                    </span>
                  )}
                </>
              );

              return (
                <li key={item.id}>
                  {item.href && !item.disabled ? (
                    <a
                      href={item.href}
                      data-slot="app-shell-nav-item"
                      aria-current={active ? "page" : undefined}
                      title={rail ? item.label : undefined}
                      onClick={(event) => {
                        if (onActiveChange) event.preventDefault();
                        selectItem(item, fromDrawer);
                      }}
                      className={sharedClass}
                    >
                      {content}
                    </a>
                  ) : (
                    <button
                      type="button"
                      data-slot="app-shell-nav-item"
                      disabled={item.disabled}
                      aria-current={active ? "page" : undefined}
                      title={rail ? item.label : undefined}
                      onClick={() => selectItem(item, fromDrawer)}
                      className={sharedClass}
                    >
                      {content}
                    </button>
                  )}
                </li>
              );
            })}
          </ul>
        </div>
      ))}
    </div>
  );

  const renderFooter = (rail: boolean) => {
    if (footer) {
      return (
        <div data-slot="app-shell-footer" className={cn("flex flex-none items-center gap-2 border-t p-2", rail && "justify-center")}>
          {footer}
        </div>
      );
    }
    if (!user) return null;
    return (
      <div
        data-slot="app-shell-footer"
        title={rail ? `${user.name}${user.detail ? ` (${user.detail})` : ""}` : undefined}
        className={cn("flex flex-none items-center gap-2.5 border-t px-2.5 py-2", rail && "justify-center px-2")}
      >
        <Avatar name={user.name} size="sm">
          {user.avatar && <AvatarImage src={user.avatar} />}
          <AvatarFallback />
        </Avatar>
        {!rail && (
          <div className="grid min-w-0 flex-1 leading-tight">
            <span className="truncate text-xs font-medium text-foreground">{user.name}</span>
            {user.detail && <span className="truncate text-[0.6875rem] text-muted-foreground">{user.detail}</span>}
          </div>
        )}
      </div>
    );
  };

  const ContentTag = contentAs;

  return (
    <div
      data-slot="app-shell"
      data-surface="panel"
      data-collapsed={isCollapsed || undefined}
      data-compact={compact || undefined}
      className={cn("@container/shell relative flex h-full min-h-80 w-full min-w-0 overflow-hidden rounded-lg border bg-card text-card-foreground", className)}
      {...props}
    >
      {/* Desktop collapsible sidebar */}
      <aside
        id={sidebarId}
        data-slot="app-shell-sidebar"
        aria-label={navLabel}
        className={cn(
          "hidden flex-none flex-col overflow-hidden border-e bg-muted/45 transition-[width] duration-200 ease-out motion-reduce:transition-none @xl/shell:flex",
          isCollapsed ? "w-[52px]" : compact ? "w-48" : "w-56",
        )}
      >
        <div
          data-slot="app-shell-sidebar-header"
          className={cn("flex flex-none items-center border-b px-2", compact ? "h-11" : "h-12", isCollapsed && "justify-center")}
        >
          {renderWorkspaceHeader(isCollapsed)}
        </div>
        <nav aria-label={navLabel} className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-2">
          {renderNavGroups(isCollapsed, false)}
        </nav>
        {renderFooter(isCollapsed)}
      </aside>

      {/* Top bar + main content canvas */}
      <div className="flex min-w-0 flex-1 flex-col">
        <header
          data-slot="app-shell-topbar"
          className={cn("flex flex-none items-center gap-2 border-b px-3", compact ? "h-11" : "h-12")}
        >
          <button
            ref={mobileToggleRef}
            type="button"
            data-slot="app-shell-mobile-toggle"
            aria-label={mobileOpen ? "Close navigation menu" : "Open navigation menu"}
            aria-expanded={mobileOpen}
            aria-controls={drawerId}
            onClick={() => setDrawer(!mobileOpen)}
            className={cn(
              "grid size-8 flex-none cursor-pointer place-items-center rounded-md text-muted-foreground transition-[background-color,color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground motion-reduce:transition-none @xl/shell:hidden",
              FOCUS,
            )}
          >
            {mobileOpen ? <XIcon size={16} /> : <MenuIcon size={16} />}
          </button>

          <button
            type="button"
            data-slot="app-shell-collapse-toggle"
            aria-label={isCollapsed ? "Expand sidebar" : "Collapse sidebar"}
            aria-expanded={!isCollapsed}
            aria-controls={sidebarId}
            aria-keyshortcuts={collapseShortcut || undefined}
            title={collapseShortcut ? `${isCollapsed ? "Expand" : "Collapse"} sidebar (${collapseShortcut})` : undefined}
            onClick={toggleCollapsed}
            className={cn(
              "hidden size-8 flex-none cursor-pointer place-items-center rounded-md text-muted-foreground transition-[background-color,color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground motion-reduce:transition-none @xl/shell:grid",
              FOCUS,
            )}
          >
            <PanelLeftIcon size={16} className="rtl:-scale-x-100" />
          </button>

          <span aria-hidden="true" className="h-4 w-px flex-none bg-border" />

          <div className="min-w-0 flex-1 overflow-hidden">
            <Breadcrumb items={resolvedBreadcrumbs} maxItems={3} />
          </div>

          <div data-slot="app-shell-topbar-actions" className="flex flex-none items-center gap-2">
            {showSearch && (
              <button
                type="button"
                data-slot="app-shell-search"
                data-surface="control"
                onClick={() => {
                  if (sound) play("open");
                  onSearch?.();
                }}
                className={cn(
                  "inline-flex h-8 cursor-pointer items-center gap-2 rounded-md border border-input bg-background px-2 text-xs text-muted-foreground transition-[background-color,color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground motion-reduce:transition-none @md/shell:px-2.5",
                  FOCUS,
                )}
              >
                <SearchIcon size={14} className="flex-none" />
                <span className="sr-only @md/shell:not-sr-only">{searchLabel}</span>
                {searchShortcut && (
                  <span aria-hidden="true" className="hidden @lg/shell:inline-flex">
                    <Shortcut keys={searchShortcut} />
                  </span>
                )}
              </button>
            )}
            {actions}
          </div>
        </header>

        <ContentTag
          data-slot="app-shell-main"
          className={cn("min-w-0 flex-1 overflow-y-auto overscroll-contain", compact ? "p-3.5" : "p-5")}
        >
          {children}
        </ContentTag>
      </div>

      {/* Container-responsive mobile navigation drawer */}
      <AnimatePresence initial={false}>
        {mobileOpen && (
          <div className="absolute inset-0 z-30 flex @xl/shell:hidden">
            <motion.div
              aria-hidden="true"
              initial={reduced ? false : { opacity: 0 }}
              animate={{ opacity: 1 }}
              exit={{ opacity: 0 }}
              transition={reduced ? INSTANT : FAST}
              onClick={() => {
                setDrawer(false);
                mobileToggleRef.current?.focus();
              }}
              className="absolute inset-0 bg-background/70"
            />
            <motion.div
              id={drawerId}
              role="dialog"
              aria-modal="true"
              aria-label={navLabel}
              data-slot="app-shell-drawer"
              initial={reduced ? false : { x: "-100%" }}
              animate={{ x: 0 }}
              exit={{ x: "-100%" }}
              transition={reduced ? INSTANT : ENTER}
              className="relative z-10 flex h-full w-60 max-w-[85%] flex-col border-e bg-[var(--thrum-base-popover,var(--popover))] text-popover-foreground shadow-md"
            >
              <div className={cn("flex flex-none items-center gap-1 border-b px-2", compact ? "h-11" : "h-12")}>
                {renderWorkspaceHeader(false)}
                <button
                  ref={mobileCloseRef}
                  type="button"
                  aria-label="Close navigation menu"
                  onClick={() => {
                    setDrawer(false);
                    mobileToggleRef.current?.focus();
                  }}
                  className={cn(
                    "grid size-8 flex-none cursor-pointer place-items-center rounded-md text-muted-foreground transition-[background-color,color] duration-150 ease-out hover:bg-accent hover:text-accent-foreground motion-reduce:transition-none",
                    FOCUS,
                  )}
                >
                  <XIcon size={16} />
                </button>
              </div>
              <nav aria-label={navLabel} className="min-h-0 flex-1 overflow-y-auto p-2">
                {renderNavGroups(false, true)}
              </nav>
              {renderFooter(false)}
            </motion.div>
          </div>
        )}
      </AnimatePresence>
    </div>
  );
}

Files and dependencies

Adds
components/app-shell.tsx
Packages
motion
Brings along
AvatarBreadcrumbKbdMotion tokensSound engine
Icons
chevrons-up-downmenupanel-leftsearchx

Changelog

  1. 1.0.0 · 2026-12-04First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor