Navigation

Sidebar

App shell sidebar with collapse-to-rail behaviour. Composable navigation.

Preview
01 Installation

Install

Pull Sidebar from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Sidebar } from "@brika/clay";
tsxGranular1 line
import { Sidebar } from "@brika/clay/components/sidebar";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxSidebar.tsx23 lines

/**
 * Sidebar is an app-shell component, it consumes a SidebarProvider context that wraps the whole app surface. A live preview inside a doc card is misleading: in real use the sidebar fills the viewport edge. Show a static screenshot-style preview here. The full doc page in apps/ui demonstrates the actual integration.
 */
export default function SidebarDefaultDemo() {
  return (
    <div className="flex w-full max-w-md overflow-hidden rounded-lg border border-clay-hairline">
      <div className="flex w-44 flex-col gap-2 border-clay-hairline border-r bg-clay-canvas p-3">
        <p className="font-medium font-mono text-[0.625rem] text-clay-subtle uppercase tracking-wider">
          Workspace
        </p>
        <ul className="space-y-0.5 text-clay-default text-sm">
          <li className="rounded bg-clay-control px-2 py-1 font-medium text-clay-strong">
            Dashboard
          </li>
          <li className="px-2 py-1">Plugins</li>
          <li className="px-2 py-1">Settings</li>
        </ul>
      </div>
      <div className="flex-1 bg-clay-elevated p-4 text-clay-subtle text-sm">Main content</div>
    </div>
  );
}
03 Accessibility

Accessibility

  • SidebarProvider exposes collapsed state via context, sync aria-expanded on the toggle button.
  • The sidebar should have role="navigation" or role="complementary" depending on content.
  • The default keyboard shortcut Cmd+B should be announced via aria-keyshortcuts on the trigger.
  • Rail-collapsed state hides labels visually; ensure icon-only items still carry aria-label.
04 Tokens 6 theme-overridable

Theme tokens

Every CSS variable Sidebar reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Sidebar without touching component code.

Sidebar tokens

6 tokens
ColorFill, border, and text colors.2
  • --sidebar-inset-containercolorvar(--background)
    components.sidebar.insetContainer

    Background of the `<SidebarInset>` main content panel that sits next to the sidebar.

  • --sidebar-input-containercolorvar(--background)
    components.sidebar.inputContainer

    Background of the `<SidebarInput>` text field nested inside a sidebar header / footer.

GeometrySizes, lengths, and corner radii.3
  • --sidebar-widthsize16rem
    components.sidebar.width

    Sidebar width when expanded.

  • --sidebar-width-iconsize3rem
    components.sidebar.widthIcon

    Sidebar width when collapsed to icon-only mode.

  • --sidebar-width-mobilesize18rem
    components.sidebar.widthMobile

    Sidebar width when shown as a mobile sheet.

ElevationDrop shadow and depth.1
  • --sidebar-backdrop-blurblur0px
    components.sidebar.backdropBlur

    Backdrop blur applied to the sidebar surface. Set non-zero for a frosted-glass treatment.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.sidebar, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "sidebar": {
      "width": "16rem"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-sidebar-…) — see the chips on each token row.

05 API reference

API reference

Props specific to Sidebar. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

Sidebar exposes no wrapper-specific props.

All props pass through to the underlying HTML / Radix primitive, see the component source linked above for the full type signature.