# Sidebar

- **[Atoms](/components/)**

An app's side navigation: a brand row, search, items with counts, groups that open and close, a foot. Works rendered on the server with no script.

## When to use

- **Use for**: The main navigation of an app or dashboard, also on pages rendered on the server with no script.
- **Not for**: A marketing site header. Use the navigation blocks.
- **Pairs with**: SidebarLayout for the shell; Input in SidebarSearch; Badge counts.

## Preview

sidebar.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { Sidebar, SidebarLayout, SidebarHeader, SidebarNav, SidebarMenu, SidebarGroup, SidebarItem } from '@/components/klarhimmel/ui/sidebar';

export default function Example() {
  return (
    <Theme theme="brand">
      <SidebarLayout sidebar={
        <Sidebar header={<SidebarHeader>Exempelhotellet</SidebarHeader>} foldLabel="Pages and search">
          <SidebarNav label="Main navigation">
            <SidebarMenu><SidebarItem href="/" current badge="3">Bookings</SidebarItem></SidebarMenu>
            <SidebarGroup label="This week" defaultOpen meta="9" inset>
              <SidebarItem href="/mon">Monday</SidebarItem>
            </SidebarGroup>
          </SidebarNav>
        </Sidebar>
      }>
        <main>…</main>
      </SidebarLayout>
    </Theme>
  );
}
```

## Import

- **CLI**

  ```
  npx shadcn add https://ui.klarhimmel.com/r/sidebar.json
  ```
- **Import**

  ```
  import { Sidebar, SidebarLayout, SidebarHeader, SidebarSearch, SidebarNav, SidebarMenu, SidebarGroup, SidebarItem, SidebarFooter, PageBar, FocusBar } from '@/components/klarhimmel/ui/sidebar';
  ```

- **Files**: sidebar.tsx, sidebar.css, in components/klarhimmel/ui/. With it: theme, tooltip, utils. npm: lucide-react.
- **Render in**: Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

## Anatomy

The parts and how they nest.

```
SidebarLayout
  Sidebar
    SidebarHeader
    SidebarSearch
    SidebarNav
      SidebarMenu > SidebarItem
      SidebarGroup > SidebarItem
    SidebarFooter
```

- **SidebarLayout**: The shell: a container, sidebar column from 56rem.
- **SidebarGroup**: A native disclosure with counts.
- **SidebarItem**: A 44 px link row; current = tint, bar and weight.

## Props

- **Sidebar.header**: Always shown, also when the rest folds away (the brand row).
- **Sidebar.foldLabel**: Inside SidebarLayout: the menu button's name under 56rem ("Menu"); the button opens the navigation as a drawer. Without it the sidebar stays above the content on a narrow screen.
- **Sidebar.closeLabel**: The same button's name while the drawer is open (it shows an X then). Default "Close menu".
- **Sidebar.rail**: A narrow rail of icons: item and group names go to screen readers and tooltips.
- **Sidebar.children**
- **SidebarLayout.sidebar**: The <Sidebar>: beside the content from 56rem of this layout's width (sticky, full height), above it when narrower.
- **SidebarLayout.children**
- **SidebarLayout.frame**: 'panels' (default; Felix 2026-10-22 14:4x "we make it the default look for all our apps"): from 64rem the sidebar and the content are rounded panels floating on a soft canvas with an even gap (sidebar.css, --kh-shell-* variables). 'flush': the sidebar column against the window edge with a line, as before. Phones keep the top bar and drawer either way.
- **SidebarLayout.focus**: A focus page (a task, a board): no sidebar, the work gets the whole width.
- **SidebarLayout.bar**: A top bar over the content (a focus page's way back, title and actions): its own floating panel in the panels frame.
- **SidebarLayout.barFlush**: The bar is one element of the app's own that fills the bar's panel edge to edge (its own surface and padding): no padding or line from the shell, its corners follow the panel's.
- **SidebarLayout.bareContent**: No content panel: the work sits on the canvas and draws its own panels (a board's columns). Panels frame only.
- **SidebarLayout.barOpen**: The bar on the canvas with no panel of its own (a board's title and zoom over its columns, Felix 28 Oct: "the title on the canvas with no panel, so the columns carry the eye"). Panels frame only.
- **SidebarLayout.scrollKey**: The page's address (a route or hash). In the panels frame from 64rem the content panel scrolls, not the window, so a host's scrollTo(0, 0) on navigation misses it: when this changes, the content panel goes back to its top.
- **SidebarHeader.action**
- **SidebarNav.label**: Names the navigation landmark. Not shown. (Or aria-labelledby.)
- **SidebarMenu.inset**: An accent count, a quiet count, and indented items for plain text links.
- **SidebarGroup.label**
- **SidebarGroup.collapsible**: false: a fixed heading, always open.
- **SidebarGroup.defaultOpen**: Whether a collapsible group starts open (a native <details>, no script needed).
- **SidebarGroup.open**: Controlled instead: a button with aria-expanded, for an app that keeps the state itself. Needs onOpenChange.
- **SidebarGroup.onOpenChange**
- **SidebarGroup.badge**: A leading icon, an accent count that wants attention, a quiet count at the end.
- **SidebarGroup.meta**: An accent count, a quiet count, and indented items for plain text links.
- **SidebarGroup.inset**: Indent the items under the heading (groups of plain text links, no icons).
- **SidebarGroup.children**
- **SidebarItem.href**
- **SidebarItem.current**: The page the person is on: aria-current, a soft fill and a heavier weight (never the fill alone); no bar at the side at any width (Felix 2026-10-21 16:2x).
- **SidebarItem.icon**
- **native attributes**: Every native attribute of the element passes through, className included.

## Accessibility

- Tab · Moves through the links and the group headings.
- Enter or Space on a group heading · Opens or closes the group.

[Accessibility](/get-started/accessibility)

[Previous](/components/breadcrumb)

[Next](/components/pagination)
