Sidebar

A React component in Beamline's Navigation category, in the free sample.

The app's main navigation: sections, items with counts and one level of sub-pages, an icon rail with tooltips (⌘B, the trigger or the edge), and a sheet on phones.

Use it for

  • The main navigation of any multi-section app; usually through app-shell.

Not for

Anatomy

  • SidebarProvider
  • Sidebar (header, nav, footer, rail)
  • SidebarSection
  • SidebarItem
  • SidebarText
  • SidebarTrigger
  • SidebarInset
  • useSidebar()

Variants

  • collapsible: icon, offcanvas, none
  • side: left, right
  • tone: default, brand, contrast

States

  • expanded
  • rail
  • hidden
  • narrow room (layout under 40rem): the rail, the person's open choice kept for when the room grows
  • open over the page (narrow room): closes on Escape, a press outside or a page chosen
  • phone sheet
  • item active
  • sub-pages open

Keyboard

  • ⌘B / Ctrl+B toggles (in a narrow room: opens it over the page)
  • Escape closes it when it is over the page
  • Tab through items
  • in the rail, focus shows the name

Motion

Width changes over 200 ms; the phone sheet slides in. In a narrow room the rail grows into the full sidebar over the page (the same 200 ms) with the overlay's shadow, and goes back into the rail. Sub-pages open and close to their own height (.disclosure-panel) while the chevron turns. The current page's tone and rule are one plate that travels to the next page chosen as matter (ui/lib/contour.ts); collapsing to the rail or a reflow places it without travel. A row press is acknowledged at once.

Props

PropTypeDefaultDescription
nav{ label?, action?, items: { label, icon?, href?, onSelect?, active?, badge?, items? }[] }[]—The navigation as data; or pass SidebarSection / SidebarItem children.
header / footerReactNode—header: Top: product mark or workspace switcher. Use SidebarText for words that should hide in the rail. footer: Bottom: account, plan usage.
collapsible"icon" | "offcanvas" | "none""icon"icon: collapses to an icon rail; offcanvas: slides away; none: always open. Default icon.
Provider open / defaultOpen / onOpenChange / storageKey / containedboolean / string—SidebarProvider controls expansion with open or starts from defaultOpen (true); onOpenChange reports requests. storageKey optionally remembers it; contained defaults to false.
SidebarProvider native props / refHTMLAttributes<HTMLDivElement> / Ref<HTMLDivElement>—Native data/ARIA/event attributes, className, style and ref all address the sidebar layout visual root. Sidebar state, keyboard shortcut and persistence retain their existing contract.
style / refCSSProperties / native Ref—style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default.
classNamesSidebarClassNames—Classes for the named visual parts; no part overrides by default.
tone"default" | "brand" | "contrast""default"Deprecated surface treatment alias; omitted by default. Deprecated: Use appearance instead.
appearance"default" | "brand" | "contrast"—default: the look's chrome. brand: printed in a deep shade of the brand with light inks. contrast: near-black with light inks in either theme. Inks, rules, hovers and the current-page rule inside follow, on every look.
refRef<HTMLElement>—Receives the documented root element; no ref by default.
styleCSSProperties—Inline styles on the documented visual root; no inline overrides by default.
sheetClassNamesPartial<Record<"root" | "scrim" | "close", string>>—Classes for the sheet component's named parts; no overrides by default.
sectionClassNamesPartial<Record<"root" | "header" | "label" | "list" | "separator", string>>—Classes for the section component's named parts; no overrides by default.
itemClassNamesPartial<Record<"root" | "row" | "label" | "dot" | "badge" | "chevron" | "submenu" | "su…—Classes for the item component's named parts; no overrides by default.
side"left" | "right"—Edge from which the panel or anchored content opens. Defaults to "left".
headerReactNode—Top: product mark or workspace switcher. Use SidebarText for words that should hide in the rail.
footerReactNode—Bottom: account, plan usage.
childrenReactNode—Content rendered inside the component. Defaults to no children.
labelstring—The landmark's name. Default "Main".
classNamestring—Classes on the documented visual root; no override by default.
SidebarProvider.defaultOpenboolean—On SidebarProvider: Initial open state when uncontrolled. Defaults to true.
SidebarProvider.openboolean—On SidebarProvider: Controlled open state; omit to use defaultOpen.
SidebarProvider.onOpenChange((open: boolean) => void)—On SidebarProvider: Reports open state after a change; no callback by default.
SidebarProvider.storageKeystring—On SidebarProvider: Remember the choice in localStorage under this key.
SidebarProvider.shortcutboolean—On SidebarProvider: ⌘B / Ctrl+B toggles the sidebar. Default true.
SidebarProvider.containedboolean—On SidebarProvider: Fill the parent box instead of the viewport (a preview, a split view).
AppShellNavItem.idstring—Optional stable navigation-item id; omitted by default.
AppShellNavItem.iconReactNode—Icon element shown beside the label. Defaults to no leading icon.
AppShellNavItem.hrefstring—URL opened when the item is activated. Defaults to a non-link item.
AppShellNavItem.onSelect(() => void)—Called when an item is activated; no handler by default.
AppShellNavItem.activeboolean—Whether this navigation item is the current page. Defaults to false.
AppShellNavItem.badgeReactNode—A count or short text at the end: unread, new.
AppShellNavItem.itemsSidebarNavItem[]—One level of sub-pages, shown under the item when it is open or active.
SidebarSection.actionReactNode—On SidebarSection: Action displayed beside the section label; omitted by default.
SidebarItem.idstring—On SidebarItem: Optional stable navigation-item id; omitted by default.
SidebarItem.iconReactNode—On SidebarItem: Icon element shown beside the label. Defaults to no leading icon.
SidebarItem.hrefstring—On SidebarItem: URL opened when the item is activated. Defaults to a non-link item.
SidebarItem.onSelect(() => void)—On SidebarItem: Called when an item is activated; no handler by default.
SidebarItem.activeboolean—On SidebarItem: Whether this navigation item is the current page. Defaults to false.
SidebarItem.badgeReactNode—On SidebarItem: A count or short text at the end: unread, new.
SidebarItem.itemsSidebarNavItem[]—On SidebarItem: One level of sub-pages, shown under the item when it is open or active.
SidebarTrigger.variantButtonVariant—On SidebarTrigger: Visual weight: primary (ink-filled), secondary, outline, ghost, danger, or accent (filled with the brand).
SidebarTrigger.sizeButtonSize—On SidebarTrigger: Height 32 / 36 / 40 px; touch 44 px for a bottom action bar on a phone.
SidebarTrigger.loadingboolean—On SidebarTrigger: Shows a loader in front of the label, sets aria-busy and ignores clicks; size and focus stay.
SidebarTrigger.lookBuiltInLook—On SidebarTrigger: Paint this button in another look than the one in force around it (DESIGN-LANGUAGE.md "Looks").
SidebarTrigger.asChildboolean—On SidebarTrigger: Render the single child (a link, a Radix trigger) with the button's look instead of a <button>.
SidebarTrigger.iconOnlyboolean—On SidebarTrigger: A square button holding only an icon (give it an aria-label). Decided by the children when left out: icon-only when no words sit anywhere among them (an icon, or a frame of icons), so `<span>Close</span>` is a label.

Built from

Used in

Dependencies

lucide-react

Import

import { Sidebar, SidebarText, SidebarSection, SidebarItem, SidebarTrigger, SidebarInset } from "@beamline/sidebar";

Get it

Sidebar is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Sidebar is included in the free MIT sample. Get Beamline · Connect your agent

More in Navigation

  • Tree view: Nested folders and records with the full tree keyboard model (arrows, Home/End, *, type to jump), depth guides, counts and animated opening.
  • Stepper: Where someone is in a multi-step flow: done steps carry a check, the current one a ring, and the line between marks fills as steps complete.
  • Table of contents: The sections of a long page beside it, with the one being read marked as you scroll: the marker travels down the rail between sections, the rail fills…
  • Tabs: Switches between panels of one object; one indicator slides to the active tab, counts sit beside labels, and the tabs a row has no room for fold into More.
  • Navigation menu: A site or docs header whose sections open into one panel that resizes and slides between them; NavigationMenuCard is the standard link row.
  • Menu bar: A desktop-style File / Edit / View bar for editor-like apps; each menu takes the same rows as the dropdown menu, and pointing moves between open menus.
  • Pagination: Moves through pages of a known length: first, last and the current page's neighbours, with an optional “41–60 of 468”. It answers to its own room…
  • User menu: The account menu behind the avatar: who is signed in, status, theme, account pages and sign out with progress; a bottom sheet on phones.
  • Breadcrumb: Where a page sits and the way back up; it shows as many levels as its room holds and folds the ones nearest the top into a menu.

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.