Skip to content

Navigation Patterns ​

Composition recipes for cross-component navigation shapes: the library ships no single "dual-rail sidebar" component — a dual rail is a composition of existing parts (oas-sidebar and friends), with scale, zoning and wiring left to the host. This page collects six shapes, each a live demo.

Dual-rail split sidebar ​

Scenario: the "workspace + navigation" two-tier structure of back-office products — a narrow icon rail on the far left carries workspace identity, and the adjacent column is the navigation panel of the current workspace (grouped menu + a footer account/capacity zone). Switching workspace on the rail switches the panel's title, default page and canvas title in sync. Two oas-sidebar instances, no new component.

Dual-rail split sidebar (rail switches workspace)

WL
StorageManage
4.2 GB of 20 GB

Current view

Daily board

The dual rail only owns navigation; the canvas stays the host's business.

Monthly revenue$286,400
Active members46
Open tasks9

Workspace: OAS Studio → OAS Console (Enterprise plan)

Pattern notes:

  1. Rail = collapsed icon strip: under collapsed the component keeps only items with a leading avatar or icon (items without either are auto-hidden); the strip width comes from --oas-sidebar-collapsed-width (68px here — the component default is 64px, and the extra 4px give the rail avatars breathing room). In collapsed mode the component hides head / body / foot by default, so the rail footer must be re-exposed explicitly (the #np-rail::part(foot) override in this page's styles) — otherwise the bottom avatar never shows. hide-toggle removes the bottom collapse button: in a dual rail the track width is a layout decision
  2. Panel = a second oas-sidebar: group declares section headers (rendered before a group's first item, auto-hidden when collapsed); the header / footer named slots carry the workspace switcher and the account zone; width comes from --oas-sidebar-width (272px). The footer avatar uses oas-avatar's text channel — by contract it renders only the first character (WL shows as W); use src for full initials
  3. Both rails are controlled highlights: active is a controlled attribute — clicking an item only emits oas-select (detail shape { value, label, group? }, see the Sidebar page), and the host must write active back. Rail writes the rail, panel writes the panel: two independent state slots
  4. The workspace mapping lives in the host: rail value → panel title copy + default page value is an ordinary lookup table. The component knows nothing about "workspaces" — exactly where this belongs in a composition
  5. The container owns scale: outer flex row + fixed height (520px here) + rounded border + overflow: hidden; both columns fill it and the footer sticks to the bottom. Everything outside navigation is the host's own canvas

A dual rail only holds up on desktop: this recipe pins the desktop shape with mobile-breakpoint="1" (on narrow screens a dual rail should collapse back to a single rail + drawer, see the mobile drawer on the Sidebar page).

Shapes on this page: Dual-rail split sidebar · Floating top bar · Classic light top bar · Expanded sidebar 272px · Slim icon rail 68px · Dark enterprise sidebar 272px

Floating top bar (horizontal-floating) ​

Scenario: a SaaS product's floating navigation bar — a rounded island hovering above the page, packing logo + menu + search + notifications + account into one bar; menu switching and notification read-state both give instant visible feedback. One oas-app-bar (position="floating" + elevated), layout owned by the host.

Floating top bar (rounded island + controlled menu + notification read-state + account menu)

OAS

Current page

Home

The island only owns navigation: page content is the host's business, floating above the canvas.

MRR$86,240
Trials312
Churn1.8%

Current page: Home

Pattern notes:

  1. position="floating" is a component shape: rounded corners + border + constant shadow (elevated) + inset on all sides (--oas-app-bar-inset, 12px by default) all come from the component; the host only provides a light page backdrop (the canvas) so the island's shadow has something to fall on
  2. The floating stage re-pins via absolute: the component's floating is position: fixed (viewport-relative); the demo stage declares position: relative and the host overrides #npf-bar { position: absolute } (document rules beat shadow :host rules), so the island floats relative to the stage — corners/shadow/inset untouched, and unlike a transform: translateZ(0) containing-block hack it does not drag the account dropdown panel (a position: fixed element inside shadow DOM, positioned from viewport coordinates) into the container's coordinate system
  3. The menu is a controlled highlight: menu items are host-drawn buttons (in slot="title", the flex:1 strut); on click the host writes back the active class and aria-current — the component knows nothing about "pages"
  4. The actions zone is an overflow collector: search (oas-input + oas-kbd ⌘K) and the bell live in slot="actions"; when space runs out the component folds overflowing items into a "···" panel (this container is wide enough not to trigger it, but it kicks in on real narrow windows). The bell's unread dot rides oas-badge's dot channel; clicking toggles read state
  5. Account menu = oas-dropdown: the trigger button (avatar + name + tier) sits in slot="trailing"; oas-select only reports the chosen value — what opens is the host's call

Classic light top bar (horizontal-classic) ​

Scenario: a tooling product's default top bar — full-bleed, one bottom divider, no rounded corners or shadow; main navigation in the middle, search + notifications + account on the right. Same anatomy as the floating bar, only position changes: the shape difference is expressed entirely by a component attribute, the host layout code is untouched.

Classic light top bar (static full-bleed + bottom divider + controlled menu)

OAS
WL

Current page

Home

Static shape: full-bleed, in normal flow; the bottom divider is one border the host adds.

Current page: Home

Pattern notes:

  1. Classic is the default shape: no position (static) means full-bleed, no rounded corners, no shadow; the component ships no bottom divider (classic design languages differ here), so the host adds border-bottom
  2. Item-by-item contrast with the floating bar: the same leading / title / actions / trailing anatomy, position="floating" elevated ↔ default static — changing shape only changes an attribute. That is the direct payoff of "shapes belong to components, layout belongs to the host"
  3. Controlled highlight works like the floating bar: click a menu item → the host writes back the active class + aria-current + canvas title, with the role="status" line announcing it

Expanded sidebar 272px (sidebar-expanded) ​

Scenario: a back-office workspace sidebar — logo + global search + grouped menu (inbox carries a badge) + a footer trial-upgrade card and preference zone; the collapse button folds the whole column into an icon rail and back; a Dark mode switch flips the demo stage's theme scope. One oas-sidebar with header/footer slots carries everything.

Expanded sidebar (272px + search + badge menu + trial card + Dark mode switch + collapse/expand)

OAS Console
Trial plan6 days left
Upgrade

Workspace

Home

Collapsing folds the column into a 64px icon rail (head/footer content hides with it); the expand button tucks into the bottom of the rail — attached to the element it controls.

Current page: Home

Pattern notes:

  1. Width rides the variable: --oas-sidebar-width: 272px overrides the component default of 220px; group declares the MENU section header, and the badge channel accepts numbers (Inbox 12) and strings (Notifications "15+")
  2. Preferences / Dark mode / Themes / Help live in the footer slot, not items: they are a "preference zone", not page navigation, and should not join the active selection semantics; oas-switch's label attribute renders a visible label (label-position=start puts it on the left), and the Dark mode switch flips the demo stage's data-theme scope — container-level token switching re-dresses the whole demo, and doubles as the smallest proof that "any container can set data-theme"
  3. Collapse/expand is a controlled attribute: the header button writes the collapsed attribute; the collapsed component hides head/body/foot (a narrow rail cannot fit that content), and the host supplies the "expand" button in the footer slot — visibility is pure CSS (a [collapsed] attribute selector + ::part(foot) to surface only that one button), so the button stays attached to the rail it controls instead of floating in the canvas; in real products this usually lives in the top bar's hamburger slot, but it is the same "host writes collapsed back" move
  4. The trial card is free-form footer content: oas-button (size=small, type=primary) + copy; the component only pins the footer to the bottom (sticky), the card's layout is the host's
  5. When content exceeds one screen the sidebar scrolls within its panel: the footer stays pinned (sticky) and menu items pass beneath it (established component semantics) — this recipe deliberately fills the column to showcase every zone; scroll to reach the remaining menu items

Slim icon rail 68px (sidebar-rail) ​

Scenario: navigation for a space-tight tooling product — a 68px icon rail parked at the edge, labels temporarily unfolding on hover without disturbing layout, the account avatar pinned at the bottom. A composition of two component attributes: collapsed + expand-on-hover.

Slim icon rail (collapsed 68px + expand-on-hover + controlled active)

WL

Current page

Home

Hover the rail to unfold labels temporarily; keyboard focus gets the built-in tooltip (component-provided, not part of this recipe).

Current page: Home

Pattern notes:

  1. 68px = --oas-sidebar-collapsed-width: the component default is 64px; the extra 4px give the icons breathing room. collapsed is controlled; items without an icon auto-hide in the collapsed state
  2. expand-on-hover is purely visual: hovering temporarily expands to --oas-sidebar-width (240px) revealing labels with a shadow, without rewriting the controlled collapsed value — the rail returns on mouse-out. Want it narrower than the 220px default when expanded? Turn that variable down too
  3. The collapsed footer re-exposure reuses the first recipe: the collapsed component hides the foot; a ::part(foot) host-level override puts the avatar back at the rail's bottom — the established "component hides by default, recipe re-exposes on demand" move
  4. Tooltips are built into the component: collapsed icon items ship a tooltip (with trigger="focus" for keyboard focus), so the recipe does not build its own floating layer

Dark enterprise sidebar 272px (sidebar-dark) ​

Scenario: an enterprise workspace sidebar under the dark theme — dark surface + primary badges + primary selection state + a trial-upgrade card and account row. The mechanism matches other demo containers on this site: set data-theme="dark" on the container to switch the token scope (same as the skin gallery); components follow along and the demo hard-codes zero color values.

Dark enterprise sidebar (data-theme=dark scope + primary badges + account row)

OAS Console
Trial plan6 days left
Upgrade

Workspace

Home

Container data-theme=dark: every color, component or host-drawn, comes from dark tokens — nothing hard-coded on either end.

Current page: Home

Pattern notes:

  1. The dark mechanism = container data-theme="dark": same as the skin gallery's preview container — token variables flip wholesale within the container's scope; oas-sidebar / oas-input / oas-button / oas-avatar and host-drawn text all follow automatically, no per-component dimming
  2. Badge and selection are primary-colored by default: the sidebar badge rides --oas-sidebar-badge-bg (falling back to --oas-color-primary) and the active item gets a light primary fill + primary text — dark contrast is guaranteed by theme tokens. A "left accent bar" is a private structure inside the component (::part cannot filter by active state), and the composition layer refuses shadow-piercing hacks; accent-bar shapes belong in component-level requests
  3. Dark card and account row: the footer trial card uses --oas-color-bg-elevated (one step lighter than the dark surface) + a border for layering; the account row is an oas-avatar text channel (first character) + email secondary text, all token colors
  4. Contrast gates: the dark demo passes the same axe run and perceptual-contrast baseline as the light ones — secondary text on the dark surface uses --oas-color-text-secondary, readable at both tiers by theme guarantee

Released under the MIT OR Apache-2.0 License.