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)
Current view
Daily board
The dual rail only owns navigation; the canvas stays the host's business.
Workspace: OAS Studio → OAS Console (Enterprise plan)
Pattern notes:
- Rail =
collapsedicon strip: undercollapsedthe 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-toggleremoves the bottom collapse button: in a dual rail the track width is a layout decision - Panel = a second
oas-sidebar:groupdeclares section headers (rendered before a group's first item, auto-hidden when collapsed); theheader/footernamed slots carry the workspace switcher and the account zone; width comes from--oas-sidebar-width(272px). The footer avatar usesoas-avatar's text channel — by contract it renders only the first character (WLshows asW); usesrcfor full initials - Both rails are controlled highlights:
activeis a controlled attribute — clicking an item only emitsoas-select(detailshape{ value, label, group? }, see the Sidebar page), and the host must writeactiveback. Rail writes the rail, panel writes the panel: two independent state slots - 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
- 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)
Current page
Home
The island only owns navigation: page content is the host's business, floating above the canvas.
Current page: Home
Pattern notes:
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- The floating stage re-pins via
absolute: the component's floating isposition: fixed(viewport-relative); the demo stage declaresposition: relativeand the host overrides#npf-bar { position: absolute }(document rules beat shadow:hostrules), so the island floats relative to the stage — corners/shadow/inset untouched, and unlike atransform: translateZ(0)containing-block hack it does not drag the account dropdown panel (aposition: fixedelement inside shadow DOM, positioned from viewport coordinates) into the container's coordinate system - 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 theactiveclass andaria-current— the component knows nothing about "pages" - The actions zone is an overflow collector: search (
oas-input+oas-kbd⌘K) and the bell live inslot="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 ridesoas-badge'sdotchannel; clicking toggles read state - Account menu =
oas-dropdown: the trigger button (avatar + name + tier) sits inslot="trailing";oas-selectonly 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)
Current page
Home
Static shape: full-bleed, in normal flow; the bottom divider is one border the host adds.
Current page: Home
Pattern notes:
- 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 addsborder-bottom - 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" - Controlled highlight works like the floating bar: click a menu item → the host writes back the active class +
aria-current+ canvas title, with therole="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)
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:
- Width rides the variable:
--oas-sidebar-width: 272pxoverrides the component default of 220px;groupdeclares the MENU section header, and thebadgechannel accepts numbers (Inbox 12) and strings (Notifications "15+") - 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
activeselection semantics;oas-switch'slabelattribute renders a visible label (label-position=start puts it on the left), and the Dark mode switch flips the demo stage'sdata-themescope — container-level token switching re-dresses the whole demo, and doubles as the smallest proof that "any container can setdata-theme" - Collapse/expand is a controlled attribute: the header button writes the
collapsedattribute; 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 writescollapsedback" move - 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 - 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)
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:
- 68px =
--oas-sidebar-collapsed-width: the component default is 64px; the extra 4px give the icons breathing room.collapsedis controlled; items without an icon auto-hide in the collapsed state expand-on-hoveris purely visual: hovering temporarily expands to--oas-sidebar-width(240px) revealing labels with a shadow, without rewriting the controlledcollapsedvalue — the rail returns on mouse-out. Want it narrower than the 220px default when expanded? Turn that variable down too- 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 - 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)
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:
- 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-avatarand host-drawn text all follow automatically, no per-component dimming - 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 (::partcannot filter by active state), and the composition layer refuses shadow-piercing hacks; accent-bar shapes belong in component-level requests - 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 anoas-avatartext channel (first character) + email secondary text, all token colors - 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