Skip to content
Klarhimmel UI

Sidebar

npx shadcn add https://ui.klarhimmel.com/r/sidebar.json
DetailsAbout, usage, props and more

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

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
  • SidebarLayoutThe shell: a container, sidebar column from 56rem.
  • SidebarGroupA native disclosure with counts.
  • SidebarItemA 44 px link row; current = tint, bar and weight.

Props

PropTypeDefaultDescription
Sidebar.headerReactNode-Always shown, also when the rest folds away (the brand row).
Sidebar.foldLabelReactNode-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.closeLabelReactNode'Close menu'The same button's name while the drawer is open (it shows an X then). Default "Close menu".
Sidebar.railbooleanfalseA narrow rail of icons: item and group names go to screen readers and tooltips.
Sidebar.childrenReactNoderequired
SidebarLayout.sidebarReactNode-The <Sidebar>: beside the content from 56rem of this layout's width (sticky, full height), above it when narrower.
SidebarLayout.childrenReactNoderequired
SidebarLayout.frame'panels' | 'flush''panels''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.focusbooleanfalseA focus page (a task, a board): no sidebar, the work gets the whole width.
SidebarLayout.barReactNode-A top bar over the content (a focus page's way back, title and actions): its own floating panel in the panels frame.
SidebarLayout.barFlushbooleanfalseThe 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.bareContentbooleanfalseNo content panel: the work sits on the canvas and draws its own panels (a board's columns). Panels frame only.
SidebarLayout.barOpenbooleanfalseThe 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.scrollKeystring-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.actionReactNode-
SidebarNav.labelstring-Names the navigation landmark. Not shown. (Or aria-labelledby.)
SidebarMenu.insetboolean-An accent count, a quiet count, and indented items for plain text links.
SidebarGroup.labelReactNoderequired
SidebarGroup.collapsiblebooleantruefalse: a fixed heading, always open.
SidebarGroup.defaultOpenboolean-Whether a collapsible group starts open (a native <details>, no script needed).
SidebarGroup.openboolean-Controlled instead: a button with aria-expanded, for an app that keeps the state itself. Needs onOpenChange.
SidebarGroup.onOpenChange(open: boolean) => void-
SidebarGroup.badgeReactNode-A leading icon, an accent count that wants attention, a quiet count at the end.
SidebarGroup.metaReactNode-An accent count, a quiet count, and indented items for plain text links.
SidebarGroup.insetboolean-Indent the items under the heading (groups of plain text links, no icons).
SidebarGroup.childrenReactNoderequired
SidebarItem.hrefstringrequired
SidebarItem.currentboolean-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.iconReactNode-
native attributesHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
TabMoves through the links and the group headings.
Enter or Space on a group headingOpens or closes the group.