# App shell

> Sidebar, nav items and top bar landmarks for application layouts.

The app shell is the frame around a signed-in product: a 240 px `Sidebar` of `NavItem` links, and a 56 px `TopBar` above the page content. They are server components made of landmarks and links; interactive parts, such as an account menu or a mobile drawer, are client components you pass in.

Pro example source is available to licensed users. See [Pro access](/docs/pro/access).

## Installation

Pro components install from the Aloxe registry with the shadcn CLI. Once per project, add the registry to `components.json` and put a [registry token](/account/tokens) in the `ALOXE_TOKEN` environment variable. [Registry](/docs/pro/registry) has the details.

```json
{
  "registries": {
    "@aloxe": {
      "url": "https://<aloxe-site>/r/{name}.json",
      "headers": { "Authorization": "Bearer ${ALOXE_TOKEN}" }
    }
  }
}
```

Then add the component:

```bash
npx shadcn@latest add @aloxe/app-shell
```

The CLI copies the source into `components/ui/aloxe/`, so it never overwrites your own `ui` components. It also installs `@aloxe/react`, `@aloxe/tokens` and `@base-ui/react`.

Import the tokens once in your global stylesheet, after Tailwind, and add an `@source` for the copied files and one for `@aloxe/react`, so Tailwind generates their classes. `@source` paths are relative to the stylesheet; these assume `src/app/globals.css` and `src/components/ui/aloxe/`.

```css
@import "tailwindcss";
@import "@aloxe/tokens/aloxe.css";
@import "@aloxe/tokens/tailwind.css";
@source "../components/ui/aloxe";
@source "../../node_modules/@aloxe/react/dist";
```

[Installation](/docs/getting-started/installation) covers the theme and brand attributes.

## Usage

```tsx
// app/(app)/layout.tsx
import Link from "next/link";
import { NavItem, Sidebar, TopBar } from "@/components/ui/aloxe/app-shell";

export default function AppLayout({ children }: LayoutProps<"/">) {
  return (
    <div className="flex h-dvh">
      <Sidebar header={<span>Northwind Studio</span>} className="hidden md:flex">
        <NavItem href="/projects" linkComponent={Link} active>Projects</NavItem>
        <NavItem href="/invoices" linkComponent={Link} count={3}>Invoices</NavItem>
      </Sidebar>
      <div className="flex min-w-0 flex-1 flex-col">
        <TopBar actions={<AccountMenu />}>
          <MobileNav />
        </TopBar>
        <main className="min-h-0 flex-1 overflow-y-auto p-6">{children}</main>
      </div>
    </div>
  );
}
```

The sidebar sets no height of its own: in a flex row it stretches to the row. Mark the current page with `active`. Under your breakpoint, hide the sidebar and put a menu button in the top bar that opens the same links, as the preview does with a [dropdown menu](/docs/components/dropdown-menu) when it is narrow.

## Examples

### Nav items

A `NavItem` has a 16 px `icon`, a label and an optional `count`. The active item uses the accent subtle background and accent text.

Pro example source is available to licensed users. See [Pro access](/docs/pro/access).

### Top bar

The top bar holds a [breadcrumb](/docs/components/breadcrumb) or the page title on the left and up to three `actions` on the right. Its height matches the sidebar header, so their hairlines line up.

Pro example source is available to licensed users. See [Pro access](/docs/pro/access).

## Accessibility

| Key | Action |
| --- | --- |
| Tab and Shift+Tab | Move through the nav items, then the top bar, then the page. |
| Enter | Follows the focused nav item. |

- The sidebar's links sit in a `nav` landmark named "Main" (change it with `label`). The top bar is a `header`, the page banner when it isn't inside `main`. Put the page content in `main`.
- The active item has `aria-current="page"` and differs by background and text colour.
- A `count` is part of the link's accessible name ("Invoices 3"). Add hidden text if the number needs a word, such as "3 unpaid".
- Icons are decorative and hidden from screen readers.
- Add a skip link to `main` before the sidebar when the nav is long.

## API reference

Every part accepts `className` and renders a `data-aloxe` attribute you can target in CSS, such as `[data-aloxe="nav-item"]`.

**Sidebar** (extends <div> + <nav>)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `header` | `ReactNode` |  |  | The 56 px top area: the product name or a workspace switcher. |
| `footer` | `ReactNode` |  |  | The bottom area, under a hairline: the signed-in account or help links. |
| `label` | `string` | `"Main"` |  | Accessible name of the nav landmark that holds the NavItems. |
| `children` | `ReactNode` |  |  | NavItems, with group labels between them. The list scrolls on its own when it is long. |
| `className` | `string` |  |  | Classes for the 240 px column, such as h-dvh or hidden md:flex. |

**NavItem** (extends <a>)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `href` | `string` |  | Yes | Where the item goes. |
| `active` | `boolean` | `false` |  | The item for the current page. Sets aria-current="page". |
| `icon` | `ReactNode` |  |  | A 16 px line icon before the label. Decorative. |
| `count` | `ReactNode` |  |  | A number after the label, such as unread items. Part of the link's accessible name. |
| `linkComponent` | `ElementType` | `"a"` |  | The element for the link, such as Next.js Link. |
| `className` | `string` |  |  | Merged with the default classes. |

**TopBar** (extends <header>)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `children` | `ReactNode` |  |  | Left side: a Breadcrumb or the page title, and a menu button for small screens. |
| `actions` | `ReactNode` |  |  | Right side, with an 8 px gap: search, notifications, the account menu. |
| `className` | `string` |  |  | Merged with the default classes. |

## Figma

Matches the **Sidebar**, **Nav item** and **Top bar** components in the Pro Figma file. Nav item `State=Active` maps to `active`; `Icon`, `Show count` and `Count` map to `icon` and `count`.

See [Figma](/docs/getting-started/figma) for where to get the file and how its names map to code.

## Pro

App shell is part of Aloxe Pro. The previews on this page are open to everyone; the Code tab shows the example source once you sign in with a Pro license. See [Access and licenses](/docs/pro/access) and [Pricing](/pricing#pro).
