Sidebar

A composable, themeable sidebar component for building application navigation layouts, with support for collapsible states, multiple visual variants, grouped menu items, and responsive mobile behaviour via a Sheet overlay.

Basic Structure

The foundational Sidebar layout using SidebarHeader, SidebarContent, and SidebarFooter sections. Each section is a composable slot that accepts any content, while SidebarMenu, SidebarMenuItem, and SidebarMenuButton provide structured navigation items with active state styling via the IsActive parameter.
Loading example…

With Groups

Organize navigation items into logical sections using SidebarGroup with a SidebarGroupLabel heading. Groups create visual separation between categories like "Platform" and "Settings", making complex navigation hierarchies easier to scan and understand.
Loading example…

Icons Only

A collapsed sidebar showing only icons, achieved by setting Collapsible to SidebarCollapsible.Icon on the Sidebar component. Wrap each SidebarMenuButton in a Tooltip to provide labels on hover, ensuring users can still identify each navigation item when text labels are hidden.
Loading example…

Inset Variant

The SidebarVariant.Inset variant places the sidebar flush against the window edge while the main content area appears visually inset with rounded corners and a subtle shadow. This creates a modern layout where the sidebar background extends to the edges and the content floats within it, commonly used in dashboard applications.
Loading example…

Floating Variant

The SidebarVariant.Floating variant renders the sidebar as a detached panel with rounded corners, a border, and shadow. This creates a card-like floating navigation panel that sits within a padded layout, giving the interface a spacious and modern appearance suited for creative tools and design applications.
Loading example…

Header with Workspace Switcher

A realistic sidebar header combining SidebarHeader with a DropdownMenu for workspace or team switching. The trigger displays the current workspace with a chevron icon, and the dropdown presents available workspaces with visual indicators and a "Create Workspace" action at the bottom.
Loading example…
A sidebar footer with a DropdownMenu for user profile actions and sign out. The trigger displays the user's avatar, name, and email, while the dropdown menu provides account management options and a destructive "Log out" action separated by dividers for clear visual grouping.
Loading example…

Full Application Layout

A complete sidebar layout combining a workspace switcher in the SidebarHeader, grouped navigation with SidebarGroup sections in SidebarContent, and a user menu in the SidebarFooter. This pattern demonstrates how all sidebar sub-components compose together for a production-ready application shell.
Loading example…

Structure

The Sidebar component is composed of several parts that work together:

Loading example…

CSS Custom Property Theming

Sidebar layout is driven by 61 CSS custom properties across 12 sub-components. Set these variables on :root to theme padding, gap, font-size, line-height, border-radius, height, icon-size, active state styling, and badge appearance — no !important or specificity battles needed. All variables have fallback values matching the default styling, so existing usage is unaffected.

Components expose data-sidebar attributes for CSS targeting: data-sidebar="menu-button", "trigger", "rail", "group", "group-label", "menu-action", "menu-sub", etc. Size variants use data-size="default", "sm", "lg" on BbSidebarMenuButton and BbSidebarMenuSubButton. Active state uses data-active="true" / "false".

Sidebar Layout & Sizing

VariableDefaultDescription
--sidebar-width16remMain sidebar width
--sidebar-width-mobile18remMobile sidebar width
--sidebar-width-icon3remCollapsed icon-only width

Menu Button (BbSidebarMenuButton)

VariableDefaultDescription
--sidebar-menu-button-heightautoItem height
--sidebar-menu-button-px0.5remHorizontal padding
--sidebar-menu-button-py0.375remVertical padding
--sidebar-menu-button-font-size0.875remDefault text size (14px)
--sidebar-menu-button-line-height1.25remDefault line height (20px)
--sidebar-menu-button-font-size-sm0.75remSmall variant text size (12px)
--sidebar-menu-button-line-height-sm1remSmall variant line height (16px)
--sidebar-menu-button-font-size-lg1remLarge variant text size (16px)
--sidebar-menu-button-line-height-lg1.5remLarge variant line height (24px)
--sidebar-menu-button-font-weight400Inactive text weight
--sidebar-menu-button-active-font-weight500Active text weight
--sidebar-menu-button-active-bgvar(--sidebar-accent)Active background color
--sidebar-menu-button-active-colorvar(--sidebar-accent-foreground)Active text color
--sidebar-menu-button-active-shadownoneActive state shadow
--sidebar-menu-button-radius0.375remBorder radius (6px)
--sidebar-menu-button-gap0.5remGap between icon and text (8px)
--sidebar-menu-button-icon-size1remIcon width/height (16px)
--sidebar-menu-button-collapsed-size2remIcon-only mode size (32px)
--sidebar-menu-button-collapsed-padding0.5remIcon-only mode padding (8px)
--sidebar-menu-button-collapsed-padding-lg0.75remLarge size icon-only padding (12px)

Group (BbSidebarGroup)

VariableDefaultDescription
--sidebar-group-py0.5remVertical padding
--sidebar-group-px0.5remHorizontal padding

Group Label (BbSidebarGroupLabel)

VariableDefaultDescription
--sidebar-group-label-height2remLabel row height (32px)
--sidebar-group-label-px0.5remHorizontal padding (8px)
--sidebar-group-label-font-size0.75remText size (12px)
--sidebar-group-label-line-height1remLine height (16px)
--sidebar-group-label-font-weight500Text weight
--sidebar-group-label-radius0.375remBorder radius (6px)
--sidebar-group-label-icon-size1remIcon width/height (16px)

Menu (BbSidebarMenu)

VariableDefaultDescription
--sidebar-menu-gap0.25remGap between menu items (4px)

Header (BbSidebarHeader)

VariableDefaultDescription
--sidebar-header-py0.5remVertical padding (8px)
--sidebar-header-px0.5remHorizontal padding (8px)
--sidebar-header-gap0.5remGap between child elements (8px)

Header Content (BbSidebarHeaderContent)

VariableDefaultDescription
--sidebar-header-content-gap0.5remGap between logo and text (8px)
--sidebar-header-content-py0.5remVertical padding (8px)
--sidebar-header-content-px0.5remHorizontal padding (8px)

Footer (BbSidebarFooter)

VariableDefaultDescription
--sidebar-footer-py0.5remVertical padding (8px)
--sidebar-footer-px0.5remHorizontal padding (8px)
--sidebar-footer-gap0.5remGap between child elements (8px)

Content (BbSidebarContent)

VariableDefaultDescription
--sidebar-content-py0.5remVertical padding (8px)
--sidebar-content-px0.5remHorizontal padding (8px)
--sidebar-content-gap0.5remGap between groups (8px)

Badge (BbSidebarMenuBadge)

VariableDefaultDescription
--sidebar-badge-height1.25remBadge height (20px)
--sidebar-badge-min-width1.25remMinimum badge width (20px)
--sidebar-badge-px0.25remHorizontal padding (4px)
--sidebar-badge-font-size0.75remText size (12px)
--sidebar-badge-line-height1remLine height (16px)
--sidebar-badge-font-weight500Text weight
--sidebar-badge-radius0.375remBorder radius (6px)
--sidebar-badge-right0.25remRight offset from button edge (4px)
--sidebar-badge-bgtransparentBadge background
--sidebar-badge-colorvar(--sidebar-foreground)Badge text color

Sub Menu (BbSidebarMenuSub)

VariableDefaultDescription
--sidebar-sub-mx0.875remHorizontal margin/inset (14px)
--sidebar-sub-px0.625remHorizontal padding (10px)
--sidebar-sub-py0.125remVertical padding (2px)
--sidebar-sub-gap0.25remGap between sub-menu items (4px)

Sub Menu Button (BbSidebarMenuSubButton)

VariableDefaultDescription
--sidebar-sub-button-height1.75remItem height (28px)
--sidebar-sub-button-px0.5remHorizontal padding (8px)
--sidebar-sub-button-gap0.5remGap between icon and text (8px)
--sidebar-sub-button-radius0.375remBorder radius (6px)
--sidebar-sub-button-font-size0.875remDefault text size (14px)
--sidebar-sub-button-line-height1.25remDefault line height (20px)
--sidebar-sub-button-font-size-sm0.75remSmall variant text size (12px)
--sidebar-sub-button-line-height-sm1remSmall variant line height (16px)
--sidebar-sub-button-icon-size1remIcon width/height (16px)

Example Override

:root {
    /* Custom active state styling */
    --sidebar-menu-button-active-bg: var(--primary);
    --sidebar-menu-button-active-color: var(--primary-foreground);
    --sidebar-menu-button-active-font-weight: 600;

    /* Remove border radius for a flat look */
    --sidebar-menu-button-radius: 0;
    --sidebar-sub-button-radius: 0;

    /* Compact spacing */
    --sidebar-menu-button-py: 0.25rem;
    --sidebar-group-py: 0.25rem;
    --sidebar-menu-gap: 0.125rem;

    /* Branded badge */
    --sidebar-badge-bg: var(--primary);
    --sidebar-badge-color: var(--primary-foreground);
}