Search

Find a component, token or page

Base · Navigation

Sidebar

The vertical navigation panel of an application, with grouped links and optional collapse.

HTML / JSPlannedReactStableReact NativeNot availableSwift (SwiftUI)PlannedGodotPlannedVueDraftSvelteDraftSolidDraft
Reviewed
Northgate Freight
Operations
  • 24

Shipments

Page content sits beside the sidebar.

Props

tsx
import {
  Sidebar,
  SidebarContent,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarInset,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarProvider,
} from "@/components/ui/sidebar"
import { PackageIcon, RouteIcon } from "lucide-react"

<SidebarProvider>
  <Sidebar>
    <SidebarContent>
      <SidebarGroup>
        <SidebarGroupLabel>Operations</SidebarGroupLabel>
        <SidebarGroupContent>
          <SidebarMenu>
            <SidebarMenuItem>
              <SidebarMenuButton isActive render={<a href="/shipments" />}>
                <PackageIcon />
                <span>Shipments</span>
              </SidebarMenuButton>
            </SidebarMenuItem>
            <SidebarMenuItem>
              <SidebarMenuButton render={<a href="/routes" />}>
                <RouteIcon />
                <span>Routes</span>
              </SidebarMenuButton>
            </SidebarMenuItem>
          </SidebarMenu>
        </SidebarGroupContent>
      </SidebarGroup>
    </SidebarContent>
  </Sidebar>
  <SidebarInset>{/* page */}</SidebarInset>
</SidebarProvider>

Overview

The sidebar holds an application's primary navigation along one edge of the window. It is a set of parts (header, groups, menu, footer) that you compose, wrapped in a provider that tracks whether it is expanded. On small screens it turns into a sheet.

When to use

  • As the main navigation of an application with more than a few sections.
  • When destinations are grouped or nested and need labels beside their icons.
  • When users switch sections often and benefit from navigation that is always visible.

When not to use

  • For sites with a few top-level pages and a horizontal header: use a Navigation menu.
  • For a temporary panel of details or a form: use a Sheet.
  • For switching views inside one page: use Tabs.
  • For commands rather than destinations: use a Menubar or Dropdown menu.

Anatomy

  1. Provider

    Wraps the layout, holds the open state and registers the toggle shortcut.

  2. Sidebar

    The panel itself. Fixed to the left or right edge, 16rem wide.

  3. Header and footer

    Pinned areas for a workspace switcher or account menu.

  4. Content

    The scrolling area between them.

  5. Group

    A section with an optional label and action.

  6. Menu, item and button

    A list of destinations. The button holds an icon and a label and can be marked active.

  7. Badge, action and sub-menu

    Optional extras on a menu item: a count, a trailing button, nested links.

  8. Trigger and rail

    A button, and a thin strip on the edge, that toggle the sidebar.

Props

The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).

PropTypeDefaultDescription
size"default" | "sm" | "lg"defaultHeight of a menu button. Set on SidebarMenuButton.
variant"default" | "outline"defaultStyle of a menu button. `outline` gives it a background and a hairline border.
groupLabelstringOperationsHeading of the group. Passed as children of SidebarGroupLabel.
isActiveboolean–Marks a SidebarMenuButton as the current page.
tooltipstring–On SidebarMenuButton, the label shown in a tooltip when the sidebar is collapsed to icons.
collapsible"offcanvas" | "icon" | "none"offcanvasOn Sidebar: slide off screen, shrink to icons, or never collapse.
side"left" | "right"leftOn Sidebar: the edge it is attached to.
onOpenChangefunction–On SidebarProvider: called when the sidebar expands or collapses.

States

Expanded
Full width with icons and labels.
Collapsed
Off screen, or icon-only with tooltips, depending on the collapsible prop.
Mobile
Hidden by default; opens as a sheet over the page.
Item hover
Accent background on the menu button.
Item active
Accent background and medium font weight.

Accessibility

Role: navigation

KeysAction
Tab/Shift+TabMoves through the links and buttons in the sidebar.
EnterFollows the focused link.
Cmd+B/Ctrl+BExpands or collapses the sidebar.
EscapeOn mobile, closes the sheet.
  • Render menu buttons as links (render={<a href=… />}) when they navigate, and set aria-current="page" on the active one.
  • In icon-only mode every button needs the tooltip prop so its label stays available.
  • The toggle button has the accessible name “Toggle Sidebar”.
  • Wrap the sidebar in a nav element or give it a label so it is exposed as a landmark.

Design tokens

Change any of these in Foundations and this component follows, in every language.

Platform notes

HTML / JS
Planned
Not built in HTML / JS yet.
React
Stable
Matches the contract with no platform differences.
React Native
Not available
Use the navigation library's drawer navigator on tablets and a bottom tab bar on phones.
Swift (SwiftUI)
Planned
Not built in Swift yet.
Godot
Planned
Not built in Godot yet.
Vue
Draft
Usage snippet only; menu buttons use as-child in place of React's render prop.
Svelte
Draft
Usage snippet only (Svelte 5); menu buttons use a child snippet in place of React's render prop.
Solid
Draft
Usage snippet only; menu buttons use the as prop in place of React's render prop.

Related