Basel Standard

Basel Standard / Docs

Sidebar

App-shell navigation system for persistent routes, compact rails, and structured workspace layouts.

Active article
Density as editorial control
The sidebar keeps issue structure, related routes, and compact status badges close to the current document.

The sidebar is not a single panel. It is a small layout system for product shells: persistent navigation, inset content, compact icon mode, mobile sheet fallback, and a set of menu primitives that stay visually consistent under all of those states. In this repo it is tuned for product-facing surfaces rather than decorative marketing chrome.

Installation

Install
Purchase access, then open /account/install to issue a registry token.

Usage

import {
  Sidebar,
  SidebarContent,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarInset,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarProvider,
  SidebarTrigger,
} from "@/components/ui/sidebar"
<SidebarProvider defaultOpen>
  <Sidebar collapsible="icon">
    <SidebarContent>
      <SidebarGroup>
        <SidebarGroupLabel>Sections</SidebarGroupLabel>
        <SidebarGroupContent>
          <SidebarMenu>
            <SidebarMenuItem>
              <SidebarMenuButton isActive>
                <span>Overview</span>
              </SidebarMenuButton>
            </SidebarMenuItem>
          </SidebarMenu>
        </SidebarGroupContent>
      </SidebarGroup>
    </SidebarContent>
  </Sidebar>
  <SidebarInset>
    <SidebarTrigger />
  </SidebarInset>
</SidebarProvider>

Why This Primitive Exists

Many product views need more than a drawer or a single nav list. The sidebar gives those interfaces a consistent shell for route structure, dense menus, badges, and collapsible behavior without rebuilding the frame on every page.

  • Use it for dashboards, archives, operations views, and settings shells with persistent navigation.
  • Prefer it when routes, counts, and section hierarchy should remain visible while the main content changes.
  • Avoid it when the page only needs a temporary side panel. That is a better fit for Sheet.

Examples

Basic App Shell

The standard pattern pairs SidebarProvider with one Sidebar and one SidebarInset. This keeps the navigation and the content column coordinated across open, collapsed, and mobile states.

Active article
Density as editorial control
The sidebar keeps issue structure, related routes, and compact status badges close to the current document.
<SidebarProvider defaultOpen>
  <Sidebar collapsible="icon">{/* navigation */}</Sidebar>
  <SidebarInset>{/* main canvas */}</SidebarInset>
</SidebarProvider>

Collapsed Rail

Icon-collapse keeps the shell available without dedicating the full width to navigation. Tooltips and badges matter more in this mode because labels are hidden.

Collapsed mode
Tooltips and badges keep the rail useful when width is reduced.
`SidebarProvider` preserves the open state and the trigger toggles between icon and full-width modes.
<Sidebar variant="floating" collapsible="icon">
  <SidebarMenuButton tooltip="Collections">
    <span>Collections</span>
  </SidebarMenuButton>
</Sidebar>

In Context

Inset mode is useful when the page content should preserve its own framed container while the sidebar remains persistent at the edge.

Main canvas
Inset layouts keep the page frame visible while navigation stays persistent.
Use inset mode when the content column should keep its own outer frame instead of touching the viewport edge.
<Sidebar variant="inset" collapsible="offcanvas">
  <SidebarContent>{/* loading states, groups, routes */}</SidebarContent>
</Sidebar>

Guidance

Start With The Layout Contract

  • Wrap the shell in SidebarProvider.
  • Put persistent navigation inside Sidebar.
  • Put the primary page content inside SidebarInset.

Choose The Right Collapse Mode

  • Use collapsible="icon" when the nav should remain available in a narrow rail.
  • Use collapsible="offcanvas" when the desktop sidebar should slide fully off screen.
  • Use collapsible="none" when the width should remain fixed.

Keep Menu Structure Legible

  • Use SidebarGroup, SidebarGroupLabel, and SidebarGroupContent to organize dense route lists.
  • Use SidebarMenuBadge for short counts, not long labels.
  • Reserve SidebarMenuAction for a small secondary control that should not compete with the main route target.

Know The Built-In Behavior

  • The provider stores desktop open state in a cookie for seven days.
  • SidebarTrigger and useSidebar().toggleSidebar() both respect mobile vs. desktop behavior.
  • Cmd+B on macOS and Ctrl+B on Windows/Linux toggle the sidebar by default.

API Reference

Layout And State

ExportPurposeNotes
SidebarProviderShared open state, mobile state, and layout CSS variables.Accepts defaultOpen, controlled open, and onOpenChange.
SidebarThe navigation container itself.Switches to a sheet on mobile.
SidebarInsetMain content region that responds to sidebar state.Use for the page canvas beside the nav.
SidebarTriggerShared toggle button.Calls the provider toggle logic for desktop and mobile.
SidebarRailNarrow hover target for edge toggling.Useful when the desktop sidebar is collapsible.
useSidebarAccess provider state and toggleSidebar().Must be called inside SidebarProvider.

Structural Exports

ExportUse it for
SidebarHeader, SidebarContent, SidebarFooterTop, middle, and bottom shell regions.
SidebarSeparatorVisual division inside the shell.
SidebarInputSearch or filter input styled for the sidebar surface.
SidebarGroup, SidebarGroupLabel, SidebarGroupAction, SidebarGroupContentGrouping routes and section-level controls.
SidebarMenu, SidebarMenuItemRoute list structure.
SidebarMenuButtonMain interactive route target.
SidebarMenuActionSecondary per-item action.
SidebarMenuBadgeCompact count or status token.
SidebarMenuSkeletonLoading placeholder for pending menu data.
SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButtonNested route hierarchy.

Key Props

ExportPropTypeDefault
SidebarProviderdefaultOpenbooleantrue
SidebarProvideropen, onOpenChangecontrolled state propsuncontrolled unless provided
Sidebarside"left" | "right""left"
Sidebarvariant"sidebar" | "floating" | "inset""sidebar"
Sidebarcollapsible"offcanvas" | "icon" | "none""offcanvas"
SidebarMenuButtonvariant"default" | "outline""default"
SidebarMenuButtonsize"default" | "sm" | "lg""default"
SidebarMenuButtonisActivebooleanfalse
SidebarMenuButtontooltipstring | TooltipContent propsundefined
SidebarMenuActionshowOnHoverbooleanfalse

Because the mobile implementation uses the shared Sheet primitive internally, the sidebar keeps a consistent overlay model when the shell collapses into a handheld layout.