# App Shell

A responsive application frame for top navigation, side navigation, and main content.

`AppShell` assembles the outer product frame while leaving navigation and page content composition to `Header` and `SideNav`. Its outer canvas uses `--background-default`, separating the SideNav and content surfaces that use `--sidebar` (`#eceff1` in light mode and `#0f0f0f` in dark mode). The document remains the scrolling container, so the side navigation can stay sticky without trapping content in a nested scroller.

```tsx
import { ArrowLeftIcon, ArrowRightIcon, FolderIcon, GearIcon, HouseIcon, LifebuoyIcon, PulseIcon, UsersIcon } from "@phosphor-icons/react";
import { AppShell, Badge, Button, Grid, Header, Separator, SideNav, Stack, Text } from "@zentara-co/zenos-ui";

const shellNavigation = [
  { label: "Overview", icon: HouseIcon },
  { label: "Projects", icon: FolderIcon },
  { label: "Activity", icon: PulseIcon },
];

function ProductSideNav({ defaultCollapsed = false }: { defaultCollapsed?: boolean }) {
  return (
    <SideNav aria-label="Workspace navigation" defaultCollapsed={defaultCollapsed}>
      <SideNav.Header
        collapsedContent={
          <SideNav.Toggle>
            <ArrowRightIcon aria-hidden="true" className="rtl:rotate-180" />
          </SideNav.Toggle>
        }
      >
        <Text weight="bold">ZENOS</Text>
        <SideNav.Toggle>
          {({ collapsed }) =>
            collapsed ? (
              <ArrowRightIcon aria-hidden="true" className="rtl:rotate-180" />
            ) : (
              <ArrowLeftIcon aria-hidden="true" className="rtl:rotate-180" />
            )
          }
        </SideNav.Toggle>
      </SideNav.Header>
      <SideNav.Content>
        <SideNav.Section label="Workspace">
          {shellNavigation.map((item, index) => (
            <SideNav.Item
              key={item.label}
              as="a"
              href={`#${item.label.toLowerCase()}`}
              active={index === 0}
              icon={<item.icon aria-hidden="true" />}
            >
              {item.label}
            </SideNav.Item>
          ))}
        </SideNav.Section>
        <SideNav.Section label="Manage">
          <SideNav.Item as="a" href="#members" icon={<UsersIcon aria-hidden="true" />}>
            Members
          </SideNav.Item>
          <SideNav.Item as="a" href="#settings" icon={<GearIcon aria-hidden="true" />}>
            Settings
          </SideNav.Item>
        </SideNav.Section>
      </SideNav.Content>
      <SideNav.Footer>
        <SideNav.Item as="a" href="#help" icon={<LifebuoyIcon aria-hidden="true" />}>
          Help and support
        </SideNav.Item>
      </SideNav.Footer>
    </SideNav>
  );
}

function AppShellExample() {
  return (
    <div className="w-full overflow-hidden rounded-xl border border-border">
      <AppShell
        height="auto"
        contentPadding={{ base: "4", lg: "6" }}
        className="min-h-[34rem] [&_[data-slot=app-shell-sidebar]]:h-[32rem]"
        sideNav={<ProductSideNav />}
        topNav={
          <Header
            start={<Text weight="bold">Security workspace</Text>}
            end={<Button size="sm">New scan</Button>}
          >
            <Badge variant="default" color="success">
              Operational
            </Badge>
          </Header>
        }
      >
        <Stack gap="5">
          <div>
            <Text type="heading" size="h4">
              Overview
            </Text>
            <Text color="subtle">Monitor projects, scans, and workspace activity.</Text>
          </div>
          <Grid columns={{ base: 1, md: 3 }} gap="4">
            {[
              ["Active projects", "18"],
              ["Scans today", "142"],
              ["Open findings", "7"],
            ].map(([label, value]) => (
              <Stack key={label} gap="2" className="rounded-lg border border-border p-4">
                <Text color="subtle" size="s">
                  {label}
                </Text>
                <Text as="p" type="heading" size="h3">
                  {value}
                </Text>
              </Stack>
            ))}
          </Grid>
          <Stack gap="3" className="rounded-lg border border-border p-4">
            <Text weight="bold">Recent activity</Text>
            <Text color="subtle">Production API scan completed without critical findings.</Text>
            <Separator />
            <Text color="subtle">Two members joined the incident response project.</Text>
          </Stack>
        </Stack>
      </AppShell>
    </div>
  );
}
```

## Import

```tsx
import { AppShell, Header, SideNav } from "@zentara-co/zenos-ui";
```

## Anatomy

```text
AppShell
├── banner
├── sideNav
├── topNav
└── main content
```

Pass complete navigation components into the named regions. `AppShell` owns the main landmark, responsive compact-navigation state, skip link, and overall surface hierarchy.

## Responsive navigation

On desktop and tablet landscape, `sideNav` stays at inline start and controls its own collapsed state. On mobile and tablet portrait, AppShell keeps a collapsed rail in the layout. Activating `SideNav.Toggle` opens the same navigation in an inline-start sheet—left in LTR and right in RTL. Selecting a navigation item closes that sheet.

Use `sideNavOpen`, `defaultSideNavOpen`, and `onSideNavOpenChange` when application state must observe or control the compact sheet. Use `SideNav`'s `collapsed` API only when SideNav is outside AppShell.

## Height and scrolling

`height="fill"` gives the shell a minimum viewport height. `height="auto"` follows its content, which is useful when the shell is embedded in another surface. In both modes, the document owns vertical scrolling and the navigation remains sticky.

## Content spacing

`contentPadding` accepts the shared responsive spacing scale:

```tsx
<AppShell contentPadding={{ base: "4", lg: "8" }}>
  <Dashboard />
</AppShell>
```

## Variants

height: fill, height: auto

## Anatomy

```text
AppShell
Header
SideNav
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| banner / topNav / sideNav | ReactNode | — | Named shell regions. |
| sideNavOpen | boolean | — | Controlled compact navigation sheet state. |
| defaultSideNavOpen | boolean | false | Initial compact navigation state. |
| onSideNavOpenChange | (open: boolean) => void | — | Runs when compact navigation changes. |
| sideNavLabel | string | Navigation | Accessible name for the compact navigation sheet. |
| contentPadding | Responsive<Spacing> | 0 | Main-region padding. |
| height | fill \| auto | fill | Viewport or content-based shell height. |
| skipLinkLabel | string | Skip to content | Accessible text for the keyboard skip link. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

AppShell renders a `main` landmark and a keyboard-accessible skip link. Give the side navigation a meaningful `aria-label`; `sideNavLabel` names the compact navigation dialog and its trigger. Keep only one top-level AppShell per application view.

Source: https://zenos-ui.pages.dev/layout/app-shell/