Components / page

AppShell

An app's frame: a bar across the top, an optional side column, and the main area.

Rendered from the package · open on its own

Summary

An app's frame: a bar across the top, an optional side column, and the main area.

APG patternnone
Built onnative elements
Statusself-tested
Since0.9.0
<AppShell
  bar={<><a href="/app" data-se="link" data-emphasis="standalone" data-intent="neutral">Command Center</a><Button size="sm" emphasis="outline">Sign out</Button></>}
  nav={<AppShell.Nav label="Command Center" items={[{ label: 'Overview', href: '/app', current: true }, { label: 'Items', href: '/app/items', count: 42 }]} />}
  style={{ '--se-banner-h': '3.5rem' }}
>
  <Header level={1} title="Overview" />
  …
</AppShell>

Built from what the system already has: Cover for the root, the Sidebar layout for the middle, the page banner for the bar, PageShell's main for the main. Nothing here is new placement; what is new is the composition, so every app stops drawing its own.

Anatomy

A <div data-se="app-shell" data-se-layout="cover"> holding the skip link, the bar (a <header>, the banner landmark), and either main alone or a body — data-se-layout="sidebar" with its divider — holding side and main. main is PageShell's: a <main> with the id the skip link targets and tabindex="-1" so the jump lands. With side="end" the body carries data-side="end" and main comes first in the DOM.

PartElementRequired
bar<header>yes
body<div>yes
mainthe caller'sthe caller's
side<div>yes
skip<a>yes
<div data-se="app-shell" data-se-layout="cover" style="--se-banner-h: 3.5rem">
  <a data-part="skip" href="#main">Skip to main content</a>
  <header data-part="bar">
    <a href="/app" data-se="link" …>Command Center</a>
    <button data-se="button" …>Sign out</button>
  </header>
  <div data-part="body" data-se-layout="sidebar" data-divider>
    <div data-part="side"><nav data-se="nav" data-orientation="vertical" aria-label="Command Center">…</nav></div>
    <main data-part="main" id="main" tabindex="-1">…</main>
  </div>
</div>

No role is written: <header> at the top of the shell and <main> already mean banner and main, and a nav in the side column brings its own landmark.

Properties

PropertyValuesDefaultWhat it does
barReact.ReactNodenoneThe bar across the top: a brand, a Nav, a sign-out — whatever the app needs. The shell arranges it, first child at the start and everything else at the end, and makes it stick.
navReact.ReactNodenoneThe side column. A vertical Nav is the usual thing; AppShell.Nav is one with orientation="vertical" set. Omitted, there is no column and main takes the width.
sidestart · endstartWhich side the column is on. start, the default, writes nothing; end puts it after main — the Sidebar layout's own data-side="end".
skipLabelstringSkip to main contentThe skip link's text. It is the first thing a keyboard reader hears.
mainIdstringmainThe id the skip link targets; main by default, and the id main carries.
childrenReact.ReactNodenoneThe main area's contents.

States

StateExpressed as
Focused:focus-visible

Behavior

The bar sticks to the top of the viewport as the page scrolls; the side column sticks under it and scrolls on its own when taller than the viewport. The skip link moves focus to main, as PageShell's does. Nothing else: the shell arranges, the app fills.

The shell keeps clear of the edges a device reserves. On a page that fills the screen, the bar, the side column and main add the device's inset to their gutter, the bar grows by the inset at the top, and main adds the inset at the bottom. Where nothing is reserved the insets are zero and nothing moves. They stay zero until the page asks to fill the screen with viewport-fit=cover in its viewport meta, and that is the app's choice. The inset is added to the gutter and is not the larger of the two: content that only touches the safe edge sits against the curve of the corner, and Toast and the fullscreen Dialog already add. A right-to-left page is read from the dir attribute, on the shell or above it.

The bar's height is declared, not measured. Set --se-banner-h on the shell to the bar's height and the side column sticks exactly under it; left at its 0px template the side sticks to the top and the bar covers its first line while scrolled. PageShell asks the same of a sticky banner, for the same reason: declared is true from the first paint, measured re-runs on every font swap.

Accessibility

Three landmarks, from the elements. The bar is a <header> at the top of the shell — the banner landmark; main is a <main>; a Nav in the side column is a navigation landmark with the name the app gives it. A screen reader's landmark list reads banner, navigation, main, which is the app.

The skip link is the first tab stop, out of the flow until focused, and lands on main — PageShell's link, the same rules, and the same test.

The side column is not a landmark of its own. It is a div; what it holds is. An <aside> would announce a complementary region around a navigation region, two landmarks for one column.

Keyboard

KeyResult
TabThe skip link first, then the bar's controls, then the side column's, then main's — document order, from the platform
Enter on the skip linkMoves focus to main

Roles, states and properties

_None written. The elements carry their own._

Focus

The skip link's jump puts programmatic focus on main, which draws no ring: the jump is the feedback. Nothing else moves focus.

Screen reader

Not recorded as verified. Stage 4 of the readiness ladder — driving each component with VoiceOver and NVDA — is unstarted across the package, and no component should claim otherwise until docs/journal/ records the session that did it.

Contrast and target size

npm run check:contrast audits every color pair this component uses across all four skins, light and dark, and fails the build on a shortfall. Two waivers are on the record in docs/audit/DEFERRED.md.

It sets no target size of its own; anything interactive inside it brings its own.

Tested

  • test/apg/app-shell.test.jsx
  • test/browser/app-shell.spec.mjs
  • test/browser/page-shell.spec.mjs
  • test/browser/safe-area.spec.mjs

Known gaps

_No upstream requirement is recorded as not applicable._

Appearance

The bar is the page banner made sticky: the surface, a hairline under it, the page gutter at its sides, the first child pushed to the start and the rest to the end, at least --se-banner-h tall. The side column sticks under the bar, scrolls on its own, and takes the gutter on its outer edge; the Sidebar layout's divider draws the line between it and main. Main takes the gutter at its sides and a step above and below; it has no measure of its own — an app's main area is as wide as the app, and a reading column inside it is the page's decision (Prose).

TokenUsed for
--se-banner-hinset-block-start, max-block-size, min-block-size
--se-borderborder-block-end
--se-border-strongborder
--se-border-widthborder, border-block-end, translate
--se-duration-fasttransition
--se-ease-standardtransition
--se-layer-overlayz-index
--se-layer-raisedz-index
--se-leading-uiline-height
--se-page-gutterinset-inline-start, padding-inline, padding-inline-end, padding-inline-start
--se-radius-mdborder-end-end-radius, border-end-start-radius
--se-space-2padding, padding-block
--se-space-3padding
--se-space-4gap, padding-block
--se-space-5padding-block
--se-space-8padding-block
--se-surfacebackground
--se-textcolor
--se-text-smfont-size
--se-weight-mediumfont-weight

Motion

None of its own. The skip link's return is PageShell's.

Content

The bar's first child is the brand or the app's name — a link home, in words. The side column's Nav is named for the app: Command Center, not Sidebar. Main's first child is the page header pattern (PageShell's Usage).

Usage

Two whole screens are drawn on the card. AppShell dashboard — a side Nav, a StatGroup and two Cards with a Header each — and AppShell editor — the canvas, an inspector <aside> at the end, the breadcrumb and the save in the bar. Each is this component's specimen under a variant name, the way Tabs vertical is Tabs', so a screen is composed from parts the specs already name and nothing is added to make it. Compose a new screen the same way before reaching for CSS.

An app, not a page. The builder's editor chrome and hosting-event's app are this; a portfolio page is PageShell. The difference is the frame: an app has a bar and a side column that stay while the content changes, and no footer; a page has a banner, a reading column and a footer, and scrolls as one.

The side column is the vertical Nav, with groups where the app has sections. A row of links belongs in the bar as a horizontal Nav; both at once is an app with two navigations, each named.

side="end" for an inspector, not for navigation — a reader expects to find the way around on the start side.

When not to use it. For a page with a footer, PageShell. For two columns inside main — an editor with a canvas and a panel — the Sidebar layout on its own, inside the shell's main.

Notes

Composed, not restated (Wave 4, L2 lead-in). Cover is the root, the Sidebar layout is the middle, the banner's row and the skip link are PageShell's rules joined to this root. The builder's .cc-bar/.cc-main and hosting-event's app frame drew the same thing; neither needed a new primitive.

The skip link and main's focus rule are shared with PageShell in the stylesheet, one rule with two roots, so the two shells cannot drift on the one thing a keyboard reader meets first.

Not an <aside>. The side column holds a landmark; it is not one.