App layout
The application shell: gradient-branded sidebar, topbar and a scrollable content region composed into one frame.
Purpose
The shell is four parts. AppLayout composes two of them — the
App sidebar on the left and the
Topbar across the top — around a scrollable <main> region that
carries your page. The Footer is not part of the frame: it closes
portal and marketing pages, which have their own header instead of this shell.
Use AppLayout as the outer frame of an admin application — one instance, at the route-layout
level, with each page rendered as its children. The frame fills the viewport (h-screen) and owns
all scrolling: the sidebar scrolls its own nav, the content region scrolls the page, and the topbar
stays put.
Example
The shell at preview height: gradient sidebar, topbar and the content region in one frame. The
topbar's theme toggle is live — it drives the same useTheme hook as this site's own toggle, so
clicking it flips the whole page's theme.
Dashboard
Open claims
128
Pending approvals
12
Pass the grouped navigation model (the same NavSection[] shape the
App sidebar takes) and the page body as children.
import { AppLayout } from "@healthmetrics/ui/app-layout";
import type { NavSection } from "@healthmetrics/ui/app-sidebar";
const nav: NavSection[] = [
{
items: [
{ label: "Dashboard", href: "/dashboard", icon: "dashboard", active: true },
{ label: "Claims", href: "/claims", icon: "claims", badge: 12 },
{ label: "Members", href: "/members", icon: "users" },
],
},
{
title: "Finance",
items: [
{ label: "Payments", href: "/payments", icon: "payments" },
{ label: "Reports", href: "/reports", icon: "reports" },
],
},
];
export default function DashboardPage() {
return (
<AppLayout sections={nav}>
<div className="mx-auto max-w-7xl space-y-4">
<h1 className="text-2xl font-bold">Dashboard</h1>
{/* page content */}
</div>
</AppLayout>
);
}Client-side navigation
The sidebar's links default to plain <a> elements, so every click is a full page load. Forward
your router's link component through renderLink — AppLayout passes it straight to the sidebar:
import Link from "next/link";
<AppLayout sections={nav} renderLink={(props) => <Link {...props} />}>
{children}
</AppLayout>;Composed, not configurable
AppLayout wires the Topbar's theme toggle to the useTheme hook for
you, but it exposes no other topbar props: the user identity stays at the defaults and the
notification count is fixed. When you need to drive those — a real name, a live unread count, a
sidebar footer slot — compose AppSidebar and
Topbar directly; the frame is a dozen lines of flexbox.
Responsive behaviour
Below the md breakpoint (768px) the sidebar is hidden entirely. AppLayout ships no drawer or
hamburger substitute, so on small screens the shell provides no navigation — supply your own
(for example a Sheet triggered from the page) if the app must work
on mobile.
Structure
| Property | Value |
|---|---|
| Frame | flex h-screen overflow-hidden, --canvas fill |
| Sidebar | 256px (w-64), --gradient-deep fill, hidden below md (768px) |
| Topbar | 64px tall (h-16) |
| Content | <main>, flex-1 overflow-y-auto, 24px padding (p-6) |
| Theme | useTheme hook wired to the topbar toggle |
Best practices
Do
- Mount one
AppLayoutat the route-layout level; render pages as its children. - Constrain wide content inside the region —
mx-auto max-w-7xlkeeps dashboards readable on large monitors. - Supply
renderLinkso navigation stays client-side. - Mark exactly one nav item
activeper page, matching the current route.
Don't
- Nest an
AppLayoutinside another — the shell is the outermost frame. - Use it for portal or marketing pages — those close with the Footer and carry their own header.
- Add another scroll container around the children — the
<main>region already scrolls. - Ship it as the only navigation on mobile — below
mdthe sidebar is gone.
Accessibility & keyboard
- The frame renders the three shell landmarks in order:
<aside>(sidebar),<header>(topbar) and<main>(your page) — screen-reader users can jump straight between them. - Only the two scroll regions move; the topbar and sidebar chrome stay fixed, so focus never scrolls out from under the controls that act on it.
- No skip link is built in. The tab order runs the full sidebar before reaching the content, so add a "skip to content" link in your app template if the nav grows long.
- Keyboard: Tab moves through sidebar links, then the topbar controls, then the page content — plain DOM order, no shortcuts of its own.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sectionsrequired | NavSection[] | — | Grouped navigation model passed through to the sidebar. |
childrenrequired | React.ReactNode | — | Page content rendered in the scrollable main region. |
className | string | undefined | — | Optional classes applied to the `<main>` content region. |
renderLink | ((props: NavLinkProps) => React.ReactNode) | undefined | — | Renders each sidebar link — forwarded to `AppSidebar`. Supply your router's link component to keep navigation client-side. |
The sections model is documented on the App sidebar page.
The full shell with live controls in Storybook