Skip to main content
Urbicon UI
source

SidebarLayout

App-shell layout for permanent-on-desktop / overlay-on-mobile sidebars. Wraps the Sidebar primitive, exposes --sidebar-width on the layout root so the main content offset works without boilerplate, and renders an optional mobile header with a hamburger opener.

The documentation site you are reading now is itself wrapped in SidebarLayout. Resize your viewport below 1024px to see the mobile hamburger header in action — the sidebar becomes a slide-in overlay with a backdrop, and the main column reflows to full width.

For non-shell sidebars (right-side detail panels, drawers inside a page), use the Sidebar primitive directly.

01 When to use

SidebarLayout is the ready-made app shell — it wires a Sidebar, a centered main column, and an optional mobile header into a responsive layout. Use it when you want a permanent sidebar on desktop with a hamburger overlay on mobile and you don't want to write the surrounding grid yourself. The component exposes --sidebar-width and --sidebar-effective-width on its root so the main-content offset animates in lockstep with the sidebar.

Pick a different layout or overlay if you need:

  • A custom outer grid (multi-region layout, header bar with brand controls, full bleed sections) — build it yourself with the Sidebar primitive directly.
  • A transient detail panel that pulls focus (backdrop + focus-trap) → Drawer.
  • A floating panel anchored to a specific element → Popover.

See the Dashboard recipe for a full app-shell demonstration.

02 Examples

Default app shell

The most common pattern — permanent sidebar on desktop, hamburger overlay on mobile. The layout exposes --sidebar-width and --sidebar-effective-width on its root, so the main content offset works without any CSS plumbing in the consumer.
Loading...
Loading syntax highlighting...

Grouped navigation with active state

Sections, icons, and an active-link pattern using SvelteKit's $page store. The mobile header surfaces the current page title for context.
Loading...
Loading syntax highlighting...

Collapsible mode (toggle on all viewports)

Set mode='collapsible' to make the sidebar toggleable on desktop too. The panel animates its width via --sidebar-effective-width and the main content offset transitions in lockstep.
Loading...
Loading syntax highlighting...

Right-side rail

Set side='right' for an inspector-style layout. The main content gets right-padding instead of left.
Loading...
Loading syntax highlighting...

03 Customization

Branded shell via slotClasses

slotClasses lets you restyle each region. sidebar* keys are forwarded into the embedded Sidebar primitive.
Loading...
Loading syntax highlighting...

Reusable preset via BlocksProvider

When the same shell look repeats across an app, register it once as a preset and reference it by name. Presets win over class overrides for cohesive hover/active/dark-mode behavior.
Loading...
Loading syntax highlighting...

Wider content column

Override the centered column width via contentMaxWidth, or pass 'none' to disable centering entirely.
Loading...
Loading syntax highlighting...

04 Accessibility

Skip-link target

The main column is rendered as <main id="main-content">, so a global skip-link with href="#main-content" jumps straight to the page content.

Sidebar landmark

Inherits the Sidebar primitive's behavior: rendered as <aside> and marked aria-hidden="true" while the mobile overlay is closed.

Mobile overlay

Body scroll is locked while the overlay is open. Pressing Escape closes the overlay (configurable via closeOnEscape), and a backdrop click also dismisses it (configurable via closeOnBackdropClick).

Reduced motion

The padding-transition on the main column uses the design system's --blocks-duration-normal and --blocks-ease-confident tokens, which respect prefers-reduced-motion.

05 API Reference

18 props
18 props

No matching properties

No matching properties

06 Installation

Import

Loading...
Loading syntax highlighting...