---
title: "App Shell · Ark UI — StyleX Blocks"
description: "The top-level application frame composing a navbar, sidebar, and main content area."
url: "https://stylexblocks.com/components/ark-ui/app-shell/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# App Shell

The top-level application frame composing a navbar, sidebar, and main content area.

- Behavior engine: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/components/base-ui/app-shell.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/app-shell.md)
- Category: Layout
- HTML page: https://stylexblocks.com/components/ark-ui/app-shell/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init
```

Then add the item as source you own:

```sh
npx stylexblocks add app-shell
```

Equivalent: `npx shadcn add @stylexblocks/app-shell`. Registry item JSON: https://stylexblocks.com/r/ark-ui/app-shell.json

## Usage

```tsx
import { AppShell, appShellFullscreen } from "#components/ui/ark-ui/app-shell.tsx";
import { Navbar } from "#components/ui/ark-ui/navbar.tsx";
import { Sidebar } from "#components/ui/ark-ui/sidebar.tsx";

export function Example() {
  return (
    // Root stacks the navbar over Content, which lays the sidebar next to
    // Main; pin it to the viewport with style={appShellFullscreen}
    <AppShell.Root>
      <Navbar.Root>{/* navbar */}</Navbar.Root>
      <AppShell.Content>
        <Sidebar.Root>{/* sidebar */}</Sidebar.Root>
        <AppShell.Main>{/* page */}</AppShell.Main>
      </AppShell.Content>
    </AppShell.Root>
  );
}
```

## Source

`components/ui/ark-ui/app-shell.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/ark-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
const appShellRoot = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    height: '100dvh',
  },
})

const appShellRootFullscreens = stylex.create({
  true: {
    position: 'fixed',
    inset: 0,
  },
})

const appShellContent = stylex.create({
  base: {
    display: 'flex',
    flex: 1,
    minWidth: 0,
    minHeight: 0,
  },
})

const appShellMain = stylex.create({
  base: {
    display: 'flex',
    flex: 1,
    flexDirection: 'column',
    minWidth: 0,
  },
})

export type AppShellFullscreen = keyof typeof appShellRootFullscreens

// defineSlotRecipe validates the shape at compile time. The generated
// fullscreen map is a boolean overlay with no `false` counterpart to default
// to, so it is exported as a composable style instead of a variant axis.
const appShellSlotRecipe = defineSlotRecipe({
  slots: {
    root: { styles: appShellRoot },
    content: { styles: appShellContent },
    main: { styles: appShellMain },
  },
  defaultVariants: {},
});

/**
 * AppShell — recipe and component colocated in one file; each part composes
 * via `asChild`. Root stacks a navbar over Content, which lays a sidebar
 * next to Main. Pin the shell to the viewport with
 * `<AppShell.Root style={appShellFullscreen}>`.
 */
const { withProvider, withContext } =
  createSlotRecipeContext(appShellSlotRecipe);

export const appShellFullscreen = appShellRootFullscreens.true;

export const AppShell = {
  Root: withProvider("div", "root", "AppShellRoot"),
  Content: withContext("div", "content", "AppShellContent"),
  Main: withContext("main", "main", "AppShellMain"),
};
```
