App

import { App, useApp } from "@o/pipeline/experimental/layouts/app";
import { Panel } from "@o/pipeline/experimental/layouts/panel";

App is a React client component that lays out a viewport-bound navigation, body, and optional context panel. It handles layout interaction and accessibility. You own routing, shortcuts, and persistence. Build the inside of each column with Panel.

Parts and hook

ExportPurpose
App.RootRegisters columns and manages their visibility, sizes, layout changes, and an optional viewport-bound footer.
App.NavigationThe navigation column. Omit it and it gets no track or trigger.
App.BodyThe body column.
App.ContextPanelThe context panel column. Omit it and it gets no track or trigger. Pass drawer to present it as a card.
App.TriggerColumn toggle with an optional tooltip and kbd hint.
App.DrawerNested context panel layers. Root controls a layer and Content renders it in the context panel stack.
App.ShortcutsRegisters the standard bracket bindings under your ShortcutProvider.
useAppReads activePanel, open, available, and isDesktop, and exposes setPanel, dismissPanel, and toggle.
useAppPanelDismissibleWhether a header in the current column shows a dismiss control. False for the context panel’s first layer on desktop.

The package also exports AppPanel, AppLayout, AppLayoutInput, AppPriority, AppRootProps, AppNavigationProps, AppBodyProps, AppContextPanelProps, and AppTriggerProps. AppPanel names a column: "Navigation", "Body", or "ContextPanel".

A column doesn’t scroll; its children do. Put a Panel.Root in each column, with a Panel.Header and the content in Panel.Body after it. Panel describes how the body scrolls and fades in each column.

On desktop the context panel is a flat pane on the canvas, like the body, and runs the full height of the layout. The edge between them shows only while you hover, drag, or focus the resize handle. Below desktop the context panel is a sheet.

For context the page works without, such as a chat opened on request, pass drawer to the context panel (<App.ContextPanel drawer>). On desktop it then renders as a drawer card, and drawers stack on it as on any card. Navigating between a page with a flat context panel and one with a drawer switches the layout instantly, without animating one into the other.

Context panel drawers

App.Drawer works only inside App.ContextPanel:

<App.Drawer.Root open={detailOpen} onClose={() => setDetailOpen(false)}>
  <App.Drawer.Content label="Detail panel">
    <DetailPanel />
  </App.Drawer.Content>
</App.Drawer.Root>

On desktop, drawers stack as non-modal cards over the flat context panel, so the rest of the page stays usable. The context panel beneath them stays as it is and becomes inert. On mobile they render as bottom sheets. A layer opened over a visible context panel leaves a strip of its parent showing, while a standalone layer fills the sheet space.

An open mobile panel covers the App.Root footer until it finishes closing. Drawers stay above the software keyboard without resizing the sheet. Base UI handles swipe to dismiss, so add data-base-ui-swipe-ignore to controls that conflict with it, such as sortable items or resize handles.

These props change how a layer opens and closes:

  • revealedOverParent={false}: for a mobile layer opened straight from the body rather than over a visible context panel. Closing it returns to the body without revealing a base context panel layer. It has no effect on desktop.
  • mobilePresentation: how a direct layer renders below desktop. The default "sheet" floats its own sheet over the panel. "inline" renders it inside the context panel card in place of the base content, with no backdrop or entrance animation, and the sheet’s swipe, Escape, and dismiss control close it. Layers revealed over a visible parent and layers opened on desktop ignore it.
  • onCloseToBase: clears the whole child stack in one transition, for consumers with route-backed layers. onClose dismisses only the active drawer.

Use "inline" when the layer is what the person opened, not something stacked on top of it. Otherwise two sheets at the same inset look like one sheet with a doubled shadow.

The presentation is fixed when a layer opens and holds until it closes. Switching would remount the portal and lose state such as a composer draft or a streaming turn, so a layer opened below desktop stays inline through a resize. An inline layer reports its close only after the surrounding sheet has left, so the base content doesn’t flash back.

Stack geometry and motion

Layers stack like cards, with up to three visible. On desktop those are the first three drawers. On mobile the context panel sheet is the bottom card, so it counts as one of the three. Each step back from the front card:

  • Darkens the whole card by 1%: the front card is 0%, then 1% and 2%. A fourth card reaches 3% and fades out.
  • Veils the card’s content towards its fill by 40%, 65%, then 80%, and makes it inert. The card’s fill, outline, and shadow stay solid.
  • Scales the card down uniformly, by 1.33% on desktop and 3.28% on mobile.

On desktop, the first drawer sits 4px from the resize handle and 12px in from the pane’s other edges and each card above it steps 8px inward, so a three-card stack shows two 8px rear edges. Deeper stacks reuse those three positions, and covered cards slide left as new ones arrive. On mobile, cards share a 12px side inset and rear cards step up 8px. Cards have a 16px radius, and the mobile backdrop is black at 20%.

Position and scale spring. Opacity, the content veil, the tint, and the backdrop follow the same timing without overshooting. One depth value drives every property, so a reversed or cancelled swipe retargets mid-flight. Cards enter and leave with their content fully veiled.

Tune the stack with these CSS variables. They’re declared on :root in app.theme.css, so sheets portalled outside the App subtree still resolve them:

VariableDefaultPurpose
--app-drawer-peek0.5remHow far each predecessor peeks out from the layer above.
--app-drawer-scale-step0.0328 (0.0133 on desktop)Scale lost per depth; fixed, never size-derived.
--app-drawer-durationvar(--duration-soft)Enter, push and stack transition duration.
--app-drawer-easevar(--ease-soft)Enter and push curve: the soft spring (99% in 250ms).
--app-drawer-exit-easevar(--ease-soft-out)Exit and un-recede curve: the softOut spring (99% in 300ms).
--app-drawer-backdrop-easevar(--app-drawer-fade-ease)Dim curve entering; it leaves on the exit fade curve.
--app-drawer-fade-easelinear()Fade, veil and tint entering: the soft spring, bounce held.
--app-drawer-exit-fade-easelinear()The same leaving: the softOut spring, held at its target.
--app-drawer-mobile-inset-x0.75remSide inset of a floating mobile sheet.
--app-drawer-mobile-inset-top6.75remGap between the top of a mobile sheet and the viewport.
--app-drawer-mobile-inset-bottommax(0.75rem, env(safe-area-inset-bottom))Gap below a mobile sheet.

Exit duration is calc(var(--drawer-swipe-strength) * var(--app-drawer-exit-base-duration)), based on var(--duration-soft-out), so a flicked sheet closes faster than a tapped one. prefers-reduced-motion removes the transitions but keeps the resting geometry, so exits still complete.

Root

<App.Root
  defaultLayout={savedLayout}
  onLayoutChange={saveLayout}
  panelShortcuts={{ Navigation: "[", ContextPanel: "]" }}
  priority="Body"
>
  <App.Navigation>
    <Panel.Root>
      <Panel.Header>Workspace</Panel.Header>
      <Panel.Body>…</Panel.Body>
    </Panel.Root>
  </App.Navigation>
  <App.Body>
    <Panel.Root>
      <Panel.Header>Deals</Panel.Header>
      <Panel.Body>
        <Panel.Content>…</Panel.Content>
      </Panel.Body>
    </Panel.Root>
  </App.Body>
  <App.ContextPanel>
    <Panel.Root>
      <Panel.Header>Deal details</Panel.Header>
      <Panel.Body>…</Panel.Body>
    </Panel.Root>
  </App.ContextPanel>
</App.Root>

The layout props work like this:

  • defaultLayout: initializes the root once. Later changes don’t reset its panel preferences or open state.
  • onLayoutChange: runs only after a user action, such as a close, resize, or resize reset. Automatic fitting, priority changes, and restoration don’t call it.
  • deferredDefaultLayout: reads browser-only storage with server-side rendering (SSR). App calls it once after hydration, merges the result with defaultLayout or Pipeline’s defaults, and applies it without animating, remounting, or calling onLayoutChange.
<App.Root
  defaultLayout={staticFallback}
  deferredDefaultLayout={readCookieLayout}
  onLayoutChange={writeCookieLayout}
>
  …
</App.Root>

App reads which columns exist from its direct App.Navigation and App.ContextPanel children on the first render, including columns inside fragments, then tracks them as they mount and unmount.

priority="Body" keeps the body’s preferred width first when space runs out, and priority="ContextPanel" favors the context panel. You can change it on a mounted root without resetting it:

const [priority, setPriority] = React.useState<AppPriority>("Body");

<button onClick={() => setPriority("ContextPanel")}>
  Prioritize context panel
</button>;
<App.Root priority={priority}>…</App.Root>;

The sandbox deals route changes priority between routes, and the inbox route has no context panel.

Sizing and visibility

Pane sizes are fixed CSS pixel values, not props:

ColumnDefault preferenceMinimum widthMaximum preference
Navigation264px204px324px
Body760px400px760px
Context panel480px480px1024px

The body grows past its maximum preference when the viewport has room.

Content caps at 41.5rem with 1rem gutters on mobile and 3rem on desktop, so at a 16px root font size the desktop column is 664 + 48 + 48 = 760px. From the 3xl breakpoint (120rem) the cap widens to 47.5rem, and pane fitting stays the same. Content and gutters scale with the root font size, while pane sizes stay in pixels.

useApp reports panel state in four values:

  • activePanel: the selected mobile panel. Selection doesn’t mean the panel is visible.
  • open: whether each panel is actually visible, including after desktop auto-fit.
  • available: whether a navigation or context panel column is registered.
  • autoHidden: which desktop panes were requested open but temporarily hidden to fit.

On desktop, a pane auto-hides when the minimum widths don’t fit. Navigation yields first by default; a pane the user explicitly reopens wins until both fit again. Auto-hiding preserves the open request, so the pane returns when space permits. A user-closed pane stays closed. useApp().autoHidden distinguishes temporary fitting from an explicit close, so consumers can explain why an expand control appeared. On mobile, one panel shows at a time.

Base UI portals don’t render on the server, so the navigation and context panel first render as a static desktop fallback, then move into their portals once after hydration. From then on, pane content stays mounted through opening, hiding, nesting, resizing, and breakpoint changes.

Columns are named containers (app-navigation, app-body, and app-context-panel) for container queries. Panel.Content caps the content rather than the column, and the body header spans the full column width, inset by the gutters. Sizes live in sizing.ts, and app.theme.css holds the grid formulas.

Persistence

AppLayout holds user preferences only:

type AppLayout = {
  Navigation: number;
  ContextPanel: number;
  Body: number;
  open: { Navigation: boolean; ContextPanel: boolean };
};

Store it in your app. Validate stored JSON before passing it to defaultLayout, and add your own version field when the format changes.

With SSR, render the same defaultLayout on the server and the first client render. Use deferredDefaultLayout for browser-only storage rather than a key or remount, which would lose nested client state and DOM listeners.

To show a saved layout before hydration, set CSS variables before the first paint:

  1. Pass an initialLayoutKey to the outer App.Root.
  2. In a synchronous script in the document head, read and validate the saved layout. Apply the same defaults, size limits, and responsive fit rules as deferred restoration.
  3. Write the five CSS variables named by getInitialLayoutCssVariables(key).

Once restoration and fitting finish, App.Root stops reading those variables, and you don’t need to remove them. Each column resets them so nested App layouts don’t inherit them.

Controls, shortcuts, and dragging

App.Root never registers global keys, and its controls show key hints only when panelShortcuts provides them. For the standard bracket bindings, render one App.Shortcuts under your ShortcutProvider and pass APP_PANEL_SHORTCUTS for the hints. Nested App roots don’t register bindings, and the outer bindings ignore focus inside them.

import { ShortcutProvider } from "@o/shortcuts";
import { App, APP_PANEL_SHORTCUTS } from "@o/pipeline/experimental/layouts/app";

<ShortcutProvider>
  <App.Root panelShortcuts={APP_PANEL_SHORTCUTS}>
    <App.Shortcuts />…
  </App.Root>
</ShortcutProvider>;

<App.Trigger
  area="ContextPanel"
  tooltip="Toggle context panel"
  kbd="S"
  render={<Button aria-label="Toggle context panel">Details</Button>}
/>;

App.Trigger can show its own kbd hint, but it never registers a binding.

Entering a column focuses its dismiss control first, then its other controls, then the column itself. The desktop navigation close stays keyboard reachable but only appears when it has visible focus, from Tab or the [ shortcut. Header controls at either end use bleed="start" and bleed="end" to align their hit areas with the column edge, except the navigation dismiss controls.

The context panel’s first layer has no dismiss control on desktop: the navigation and the ] shortcut collapse it, and each drawer stacked over it keeps its own close. Custom headers read useAppPanelDismissible() to match, and mark their dismiss controls with data-app-dismiss-desktop="" or data-app-dismiss-mobile="". Focus skips controls in inert layers. To clear transient content after a single-panel slide, use onPanelTransitionComplete on App.Root. It doesn’t fire for desktop collapses.

The navigation sits on the background fill and the body on the canvas, so the body reads as a sheet raised over the navigation. The app-edge utility draws the edge between them: a half-pixel ring and two soft shadows on the navigation’s end edge, plus a one-pixel highlight on the body. Below desktop the navigation sheet sits over the body and uses app-edge-raised, which casts the shadows outward onto the body instead. Both flip under RTL.

On desktop, drag a separator anywhere along its divider, resize with the arrow keys from its focused pill, double-click to reset, or drag it closed. Pointer focus keeps arrow-key resizing without a focus ring, and dragging is off below desktop. Header regions expose data-desktop-drag for app shells with native window dragging, so keep interactive controls and portalled overlays out of them. Test window dragging on macOS in the real shell, including traffic-light clearance, a collapsed navigation, narrow windows, menus, and dialogs.