Talisman LogoTalisman Logo Design System
Browse documentation
Components

App shell

The application frame, with a collapsible sidebar, a top bar and the main area, that turns the sidebar into a sheet on small viewports.

Stableimport { AppShell } from "@repo/ui/app-shell";Source
Ir para o conteúdo

Revisar contestação

Processo 0001234-56.2024.8.26.0100. Aguardando o revisor.

Use the button at the foot of the sidebar to collapse and expand it. The preview shows the desktop layout; narrow the browser window below 768px to see the sheet.

When to use

  • As the outer frame of a signed-in application: it holds the primary navigation, a top bar and the page.
  • When the product needs keyboard users to skip the navigation, and a navigation that works on small viewports.

When not to use

  • Pages without product navigation, such as sign-in or a public page. Render the page directly.
  • A panel inside a page. Use a Card, or Tabs to split content.
  • Navigation content itself. Build it with the Sidebar.

Anatomy

Part Role
LayoutProvider Holds the layout state: sidebar open, mobile sheet open, fullscreen, and what to show. Import from @repo/ui/layout-provider.
AppShell Renders the sidebar, the sheet, the top bar and main. Must be inside a LayoutProvider.
sidebar A component you write. It receives collapsed and onNavigate. Build it with Sidebar.
header Content of the top bar, such as a Breadcrumb.
useLayout() Hook to read and change the layout state from any child. Throws outside the provider.

Layout state

State Default Meaning
open false Desktop sidebar expanded. LayoutProvider defaultOpen sets it, so the default starts collapsed.
openMobile false Navigation sheet open. Always starts closed.
config all true showSidebar, showMobileSidebar, showTopbar. Change with setConfig or defaultConfig.
isFullscreen false Hides the sidebar, the top bar and the sheet for focused work. setFullscreen(true).

Examples

Expanded sidebar

Ir para o conteúdo

Revisar contestação

Processo 0001234-56.2024.8.26.0100. Aguardando o revisor.

Collapsed sidebar

Pass defaultOpen={false} to the provider (the default). The sidebar is 56px wide and shows icons.

Ir para o conteúdo

Revisar contestação

Processo 0001234-56.2024.8.26.0100. Aguardando o revisor.

Without the top bar

Set defaultConfig={{ showTopbar: false }}. On small viewports a bar with the menu button remains, so the user can still open the navigation.

Ir para o conteúdo

Revisar contestação

Processo 0001234-56.2024.8.26.0100. Aguardando o revisor.

collapsible="none" keeps the sidebar expanded and removes the toggle.

Ir para o conteúdo

Revisar contestação

Processo 0001234-56.2024.8.26.0100. Aguardando o revisor.

Collapsed, expanded and small viewports

  • Expanded: 256px wide (w-64), content receives collapsed={false}.
  • Collapsed: 56px wide (w-14), content receives collapsed={true} and should show icons with tooltips. The width changes over 300ms.
  • Below 768px (md): the sidebar is hidden. A menu button in the top bar opens a sheet from the left, 288px wide, with the same sidebar content always expanded and a close button. Pressing Escape, clicking outside or choosing an item (the content calls onNavigate) closes it.
  • Resizing the window to 768px or wider closes the sheet.
  • showCollapseToggle={false} removes the shell’s own toggle, for sidebars that place one in their footer, as apps/app does.
  • Every string is passed in labels.

The preview frame has a fixed height and the class [&>div]:h-full: the shell is h-svh (the height of the viewport) and the override is how an app, such as apps/us-app, fits it in a smaller box.

Content

  • Labels are translated copy from the app: “Navegação principal”, “Abrir navegação”, “Fechar navegação”, “Expandir menu lateral”, “Recolher menu lateral” and “Ir para o conteúdo”.
  • Put one thing in the top bar: a breadcrumb or the page title.
  • The page content starts inside main. Give the page one heading, “Revisar contestação”.
  • Links inside use CustomLink in the apps.

Accessibility

  • The desktop sidebar is an aside named by labels.navigation. The content you render should hold a nav.
  • A skip link (“Ir para o conteúdo”) is the first focusable element. It stays hidden until focused and moves focus to main, which has tabIndex={-1} so it can receive it.
  • The collapse toggle is a Button with aria-expanded, aria-controls pointing to the sidebar, and an aria-label that changes between expand and collapse.
  • The mobile sheet is a Radix Dialog: focus moves into it, stays inside, and returns to the menu button on close. Escape closes it. Its title is labels.navigation.
  • The menu button and the close button have aria-labels from labels and 48px hit targets.
  • The sheet’s open and close animations are disabled with motion-reduce.

Code

import { AppShell } from "@repo/ui/app-shell";
import type { SidebarRenderProps } from "@repo/ui/app-shell";
import { LayoutProvider } from "@repo/ui/layout-provider";

const Navigation = ({ collapsed, onNavigate }: SidebarRenderProps) => (
  /* SidebarContainer and SidebarItem */
);

<LayoutProvider defaultOpen>
  <AppShell
    header={<DynamicBreadcrumb />}
    labels={labels}
    sidebar={Navigation}
  >
    {children}
  </AppShell>
</LayoutProvider>;

Props

AppShell
PropTypeDefaultDescription
childrenReactNode—Page content, rendered inside `main`
collapsible"icon" | "none"icon`icon` lets the desktop sidebar collapse to icons; `none` keeps it expanded. Mobile always uses a sheet
headerReactNode—Content of the top bar, such as a breadcrumb
labels{ navigation, openNavigation, closeNavigation, expandSidebar, collapseSidebar, skipToContent }—Every accessible string of the shell, translated by the app
showCollapseTogglebooleantrueRenders the collapse button at the foot of the sidebar. Pass `false` when the sidebar content has its own toggle
sidebarComponentType<SidebarRenderProps>—Component rendered in the desktop sidebar and in the mobile sheet. Receives `collapsed` and `onNavigate`
AppShell labels
PropTypeDefaultDescription
navigationstring—Name of the sidebar landmark and title of the sheet.
openNavigation, closeNavigationstring—Accessible names of the menu button and of the sheet's close button.
expandSidebar, collapseSidebarstring—Accessible name and tooltip of the collapse toggle.
skipToContentstring—Text of the skip link.
LayoutProvider
PropTypeDefaultDescription
defaultOpenbooleanfalseInitial desktop state: `true` for expanded.
defaultConfigPartial<LayoutConfig>—Initial `showSidebar`, `showMobileSidebar` and `showTopbar`. All default to `true`.

Known issues

Issue Effect
The shell root is h-svh. It cannot fill a container that is smaller than the viewport without an override such as [&>div]:h-full.
The desktop sidebar has transition-all duration-300 with no motion-reduce variant. The width animation runs for users who asked for reduced motion. apps/us-app disables it with a global rule.
The 768px breakpoint is hardcoded in a matchMedia call and also in the md: classes. The two must be changed together or the sheet and the sidebar disagree.
The components import siblings through @repo/ui/... instead of relative paths. The file depends on the package resolving itself, unlike the other components.
Edit this page on GitHub