Shell
Shell, an application's whole frame from its routes: a skip link, a Topbar (sidebar trigger, brand, ⌘K search, actions), a grouped Sidebar that sticks under it, collapses (remembered) and is a drawer on narrow screens, a command palette whose Go to group reaches every route, a MobileNav bottom bar with More on narrow screens, and the main landmark. Router-agnostic: onNavigate for a history router, #/route hrefs for a hash router, or plain fast links.
Example
Installation
Usage
The frame of an application from one list of routes: pass routes, groups, currentHref and onNavigate (or plain or #/route hrefs), a brand and actions, and put each page in a PageLayout inside it; main fill (on the Shell or a route) is for an editor or workspace that fills the height left. Use DocsLayout instead for documentation with a table of contents.
API reference
RouteIcon
| Prop | Type | Default |
|---|---|---|
routerequired | ShellRoute | – |
className | string | – |
ShellSidebarSections
| Prop | Type | Default |
|---|---|---|
sectionsrequired | readonly ShellRouteSection[] | – |
currentIdrequired | string | undefined | – |
navigaterequired | NavigateTo | – |
intentPreloads a route by id when someone is about to follow it. Stable, like `navigate`. | NavigateTo | – |
ShellSearch
| Prop | Type | Default |
|---|---|---|
controllerrequired | CommandDialogController | – |
sectionsrequired | readonly ShellRouteSection[] | – |
currentIdrequired | string | undefined | – |
navigaterequired | NavigateTo | – |
labelsrequired | ShellSearchLabels | – |
commandGroups | ReactNode | – |
onCommand | (value: string) => unknown | – |
queryThe search text, to control it. Without it, every open starts from `defaultQuery`. | string | – |
defaultQueryThe search text each open starts from, when `query` doesn't control it. Empty by default. | string | – |
onQueryChange | CommandProps["onQueryChange"] | – |
footerUnder the list, like key hints. Nothing by default. | ReactNode | – |
Shell
Takes ShellProps<Route>.
Other exports
currentRouteIdmobileRoutesplacedInsectionRoutesShellSidebarContextuseShellRoutesuseShellSidebaruseMobileNavItemsgoToPrefixshellLabelstype ShellMaintype ShellRoutetype ShellPlacementtype ShellRouteGrouptype ShellRouteSectiontype ShellCurrenttype MobileRoutestype NavigateTotype ShellSearchLabelstype ShellSearchPropstype ShellLabelstype ShellPropsAccessibility
- A skip link first, to the <main> landmark, which takes focus (tabIndex -1) without changing the URL, so hash routers keep their route.
- The sidebar and the bottom bar are navigation landmarks named by labels.sidebar and labels.mobileNav; the current route carries aria-current="page" in both, and in the palette.
- On narrow screens the topbar's trigger opens the sidebar as a drawer; Escape closes it and focus returns to the trigger. The palette (Ctrl/⌘+K) returns focus the same way: it opens with an empty search, and one Escape closes it whatever the search holds.
- The bottom bar is sticky at the end of the shell rather than fixed, so the page always ends above it, also inside a pane or an iframe; scroll margins keep focused elements clear of the topbar and the bar.
Agent actions
Every route is a sidebar Link with a follow action that calls onNavigate (or loads the href), so agents follow routes by name. The palette's Go to commands (link commands to each route's href) are listed under the palette once its Search trigger is pressed; agents collapse and expand the sidebar by its name. sidebarShortcut presses that same trigger, so it adds nothing new for agents.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.