suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Patterns19
  • Overview
  • Action Bar
  • Action Menu
  • App Shell
  • Command Palette
  • Confirm
  • Context Actions
  • Date Picker
  • Flyout
  • Modal
  • Navbar
  • Paged List
  • Panel
  • Picker
  • Preview
  • Search Picker
  • Segment Picker
  • Split View
  • Table List
  • Trail

suiss/ui ยท Pattern

App Shell

An application frame with a collapsible sidebar on desktop and a floating tab bar on mobile.

App Shell is an open-source pattern from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"

const items: AppShellItem[] = [
  {
    value: "home",

AppShell builds navigation from an items array and wraps your page content. On desktop it renders a collapsible Sidebar and the page renders in a SidebarInset. On mobile a TabBar pinned to the bottom of the screen replaces the sidebar.

Use it as the outermost layout of an app with a handful of top-level destinations.

Installation

$ pnpm dlx shadcn@latest add @esuiss/app-shell

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns app-shell
  1. Add the cn helper.

  2. Add the pieces it builds on: Sidebar, Tab Bar.

  3. Copy and paste the following code into your project.

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

import * as React from "react"
import {
  Sidebar,
  SidebarContent,
  SidebarFooter,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarHeader,
  SidebarInset,
  SidebarMenu,
  SidebarMenuBadge,
  SidebarMenuButton,
  SidebarMenuItem,
  1. Update the import paths to match your project setup.

Usage

import { AppShell, type AppShellItem, AppShellTrigger } from "@/components/patterns/app-shell"
const items: AppShellItem[] = [
  { value: "home", label: "Home", icon: <HouseIcon /> },
  { value: "inbox", label: "Inbox", icon: <TrayIcon />, badge: 12 },
  { value: "settings", label: "Settings", icon: <GearIcon /> },
]

<AppShell items={items}>
  <header className="flex h-14 items-center gap-2 border-b px-4">
    <AppShellTrigger />
    <h1 className="text-base font-semibold">Home</h1>
  </header>
</AppShell>

Examples

With header and footer

Use header and footer to add a brand menu at the top of the sidebar and an account menu at the bottom.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,

Grouped

Items with the same group render under a shared SidebarGroupLabel, here Platform and Workspace. Set disabled on an item to disable it.

import {
  CalendarBlankIcon,
  ChartBarIcon,
  FolderIcon,
  GearIcon,
  HouseIcon,
  LifebuoyIcon,
  TrayIcon,
  UsersIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"

More tab

Uses eight items with defaultValue. Items that do not fit in the mobile tab bar move behind its More trigger, whose text comes from moreLabel.

import {
  CalendarBlankIcon,
  ChartBarIcon,
  FolderIcon,
  GearIcon,
  HouseIcon,
  LifebuoyIcon,
  TrayIcon,
  UsersIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"

Links

Gives every item an href so each renders as a link to its route through render.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"

const items: AppShellItem[] = [
  {
    value: "home",

Floating

Set variant="floating" to use the floating sidebar style.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,

Inset

Set variant="inset" to use the inset sidebar style.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,

Offcanvas

Sets collapsible to offcanvas so collapsing slides the whole sidebar out of view.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,

Right side

Set side="right" to place the sidebar on the right.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,

Collapsed

Set defaultOpen={false} to start with the sidebar collapsed to icons. Collapsed items show their label in a tooltip.

import {
  CalendarBlankIcon,
  GearIcon,
  HouseIcon,
  TrayIcon,
} from "@phosphor-icons/react"
import * as React from "react"
import {
  AppShell,
  type AppShellItem,
  AppShellTrigger,
} from "@/components/patterns/app-shell"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,

Accessibility

  • The selected item has aria-current="page".
  • Collapsed sidebar items show their label in a tooltip on hover.
  • AppShellTrigger is labelled Toggle Sidebar, and Cmd+B on macOS or Ctrl+B elsewhere toggles the sidebar.
  • With collapsible="offcanvas", the hidden sidebar is removed from view and the tab order.
  • Disabled items are disabled buttons.

API Reference

AppShell

The root layout that renders the sidebar or tab bar from items and wraps the page content.

PropTypeDefault
itemsAppShellItem[]Required
valuestring-
defaultValuestringFirst item
onValueChange(value: string) => void-
headerReact.ReactNode-
footerReact.ReactNode-
variant"sidebar" | "floating" | "inset""sidebar"
collapsible"offcanvas" | "icon" | "none""icon"
side"left" | "right""left"
railbooleantrue
openboolean-
defaultOpenbooleantrue
onOpenChange(open: boolean) => void-
moreLabelstring"More"
labelstring"Main"
classNamestring-
childrenReact.ReactNode-
PropTypeDefault
renderReact.ReactElementA plain a
PropTypeDefault
render(props: React.ComponentProps<"a">) => React.ReactNodeA plain a

Each AppShellItem has a value, label and icon, plus optional href, badge, group and disabled. The selected item is controlled with value and onValueChange, or uncontrolled with defaultValue; it defaults to the first item. open, defaultOpen and onOpenChange hold the sidebar's expanded state. rail renders a rail along the sidebar edge that toggles it, only when collapsible is not none. label names the navigation landmark on mobile.

Items with an href render as the render element, a plain anchor by default, so you can pass your router's link component.

Items with an href render through the render function, a plain anchor by default, so you can return your router's link component. It receives the link props, including href.

Below the 48rem breakpoint the content renders in a main element padded to clear the tab bar. className applies to the content area on both layouts. The sidebar sets data-state (expanded or collapsed), data-collapsible, data-variant and data-side, and on mobile the wrapper and content set data-slot="app-shell" and data-slot="app-shell-content", for styling.

AppShellTrigger

A SidebarTrigger that toggles the sidebar on desktop and renders nothing on mobile.

Also accepts the props of React.ComponentProps<typeof SidebarTrigger>.

Place it in your page header to toggle the sidebar.

NextCommand PalettePreviousAction Menu

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • With header and footer
    • Grouped
    • More tab
    • Links
    • Floating
    • Inset
    • Offcanvas
    • Right side
    • Collapsed
  4. 04Accessibility
  5. 05API Reference
    • AppShell
    • AppShellTrigger