AppShell
App layout with a nav, the canvas, and a resizable right panel
pnpm add @wandercom/design-system-web
AppShell lays out a dashboard screen: an optional Sidebar on the left, the canvas (usually a PageShell) in the middle, and an optional right panel for Ask Wander, Help or details. It owns the surface-canvas background (the same as surface-secondary, #f7f7f7 in light mode) and lays the canvas flush with the top, bottom and right edges. A PageShell inside AppShell.Main takes the canvas card's shape itself, rounded 16px on the left only, with no border and a soft shadow, so place it at the root of the page. Fill the panel with RightPanel.
The panel and the nav affect each other, so AppShell holds the state for both. Read it with useAppShell() inside the shell, and pass it to Sidebar and your NavItems.
import { AppShell, useAppShell } from '@wandercom/design-system-web/blocks/app-shell';
import { PageShell } from '@wandercom/design-system-web/blocks/page-shell';
import { RightPanel } from '@wandercom/design-system-web/blocks/right-panel';
import { Sidebar } from '@wandercom/design-system-web/blocks/sidebar';
import { NavItem } from '@wandercom/design-system-web/ui/nav-item';
function Nav() {
const { navCollapsed, setNavCollapsed, navRail } = useAppShell();
return (
<Sidebar collapsed={navCollapsed} onCollapsedChange={setNavCollapsed}>
<NavItem href="/home" icon={<IconHome />} rail={navRail}>
Home
</NavItem>
</Sidebar>
);
}
export function Layout() {
const [panelOpen, setPanelOpen] = useState(false);
return (
<AppShell panelOpen={panelOpen} onPanelOpenChange={setPanelOpen}>
<AppShell.Sidebar>
<Nav />
</AppShell.Sidebar>
<AppShell.Main>
<PageShell>…</PageShell>
</AppShell.Main>
<AppShell.Panel>
<RightPanel>
<RightPanel.Header>
<RightPanel.Title icon={<IconSparkles />}>Ask Wander</RightPanel.Title>
<RightPanel.Close />
</RightPanel.Header>
<RightPanel.Body>…</RightPanel.Body>
</RightPanel>
</AppShell.Panel>
</AppShell>
);
}The parts are also available as AppShellSidebar, AppShellMain and AppShellPanel.
The Ask Wander body uses ChatComposed. The chat scrolls itself, so give the body overflow-hidden.
While closed, the panel takes no width, shows nothing and is inert, so it's out of the tab order. Opening and closing animate the panel's column over 240 ms, and the canvas resizes with it. The panel's content keeps its width while it animates, so it doesn't reflow. With reduced motion, there's no animation.
Open the panel from your own state, or from anywhere inside the shell with useAppShell().setPanelOpen. When the panel closes, focus goes back to whatever had it when the panel opened.
Show RightPanel.Back for nested views, such as a Help article. The panel keeps its title, so update it for the nested view.
Leave out AppShell.Sidebar for screens with no nav, such as onboarding. The canvas then takes its own left inset. The nested view above has no nav.
The panel's body scrolls separately from the canvas.
The panel is 360 px wide by default. Drag its left edge to resize it from 288 to 720 px, or focus the handle and use the arrow keys to move it 16 px at a time. Home and End jump to the narrowest and widest. Double-click the handle to reset it. The panel never leaves the canvas narrower than 360 px.
To remember the width, pass panelWidth and persist it in onPanelWidthChange. It fires on every step while dragging, so debounce any network writes.
Below the 2xl breakpoint (1440 px), opening the panel shrinks the nav to its rail. Closing the panel restores the user's own collapsed state. If the user expands the nav while the panel is open, it stays expanded until the panel closes.
navCollapsed includes the auto-rail, so pass it to Sidebar's collapsed. onNavCollapsedChange only fires for the user's own changes, so it's safe to persist. navRail also applies Sidebar's own breakpoints, so pass it to NavItem's and NavSectionHeader's rail.
Clicking or tapping the canvas's left edge collapses and expands the nav, wired to setNavCollapsed; Sidebar has no toggle of its own. To expand it from the page header too, render a SidebarTrigger there while navCollapsed is true. The edge only renders with an AppShell.Sidebar to toggle, and is hidden below 1024 px (SIDEBAR_DESKTOP_QUERY), where Sidebar is a drawer.
Below the xl breakpoint (1288 px), the panel opens as a full-screen sheet over the canvas, with the same header. useAppShell().panelSheet tells you when it does.
The shell uses the standard surface and border tokens. The sheet and menus render in a portal, so set data-theme on the RightPanel and on any menus as well.
PageShell is a container query container, so pages can respond to the canvas width rather than the viewport. The canvas gets about 360 px narrower when the panel opens.
<div className="grid gap-3 @3xl:grid-cols-3">…</div>AppShell has no routing, data or panel content of its own, so it works in Vite and Next.js apps. Keep the panel's open state and width in the app, so they survive route changes.