Skip to content
Haze UI

Sidebar

Grouped side navigation with native disclosures, active links, and slots for a workspace header and utility links.

pnpm dlx shadcn@latest add @haze/sidebar
Open preview in a new tab
Liveno JavaScript

When to use

  • A dashboard or documentation site needs persistent navigation with one level of grouping
  • The sidebar needs a workspace switcher or footer utilities supplied by the application

When not to use

  • The sidebar is hidden behind a mobile trigger. Compose it with drawer.
  • The links point to headings on a single page. Use table-of-contents.

Installation

Add the Haze registry to components.json once, then install Sidebar with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/sidebar
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
groups*{ label: string; icon?: AstroComponent; links: SidebarLink[]; open?: boolean }[]–Each group contains page links with label, href, optional icon and detail, and current-page state. A group with the current page starts open.
labelstring"Sidebar navigation"Accessible name of the navigation landmark.
classstring–Additional classes for placement or sizing.

Keyboard interactions

EnterSpace
Toggle the focused group.
TabShiftTab
Move among summaries, revealed page links, and slotted controls.

Accessibility

  • Each group is a native disclosure. Groups can remain open independently.
  • Mark the selected page with current. It has a text-weight change, a different fill, and aria-current.
  • Use the header slot for a workspace name and the footer slot for links such as help.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Sidebar" with `npx shadcn@latest add @haze/sidebar`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Sidebar from "@/components/haze/ui/sidebar.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/sidebar.md

  • Customize with real content

    Adapt the Haze sidebar ui for our product. Replace the demo values of these props with our real content: groups, label, class. Keep the layout, the heading level rules and these accessibility details: Each group is a native disclosure. Groups can remain open independently. Mark the selected page with current. It has a text-weight change, a different fill, and aria-current. Use the header slot for a workspace name and the footer slot for links such as help. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using sidebar, check it fits: use it when a dashboard or documentation site needs persistent navigation with one level of grouping; the sidebar needs a workspace switcher or footer utilities supplied by the application. Avoid it when the sidebar is hidden behind a mobile trigger. compose it with drawer.; the links point to headings on a single page. use table-of-contents.. Alternatives: @haze/navigation-menu, @haze/table-of-contents, @haze/bottom-navigation, @haze/drawer.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog