Skip to Content
Documentation
Getting startedComponentsChartsTheming
Get Pro
Overview
Concepts

Sidebar

Collapsible side navigation, typically used as the primary navigation of SaaS applications.

SourceStorybookRecipe
Dashboard
Inbox
12
Contacts
Projects
Website redesign
Mobile app
Settings

Anatomy

import { Sidebar } from '@/components/ui/sidebar'
<Sidebar.Provider>
  <Sidebar.FlyoutTrigger />
  <Sidebar.Root>
    <Sidebar.Header></Sidebar.Header>
    <Sidebar.Body>
      <Sidebar.Group>
        <Sidebar.GroupHeader>
          <Sidebar.GroupTitle>Navigation</Sidebar.GroupTitle>
        </Sidebar.GroupHeader>
        <Sidebar.GroupContent>
          <Sidebar.NavItem>
            <Sidebar.NavButton>Home</Sidebar.NavButton>
          </Sidebar.NavItem>
        </Sidebar.GroupContent>
      </Sidebar.Group>
    </Sidebar.Body>
    <Sidebar.Footer></Sidebar.Footer>
  </Sidebar.Root>
  <Sidebar.Backdrop />
</Sidebar.Provider>

Usage

App shell

Combine the sidebar with the AppShell component to create a typical application layout. The sidebar collapses automatically on mobile and renders a backdrop overlay.

Home
Contacts

Contacts

Your application content

Inset variant

Set variant="inset" on Sidebar.Provider and wrap your main content in Sidebar.Inset to render it as a raised panel on top of the sidebar background.

Dashboard
Inbox
Reports

Dashboard

The content area is rendered as an inset panel.

Grouped navigation

Use Sidebar.Group with a GroupTitle to organize navigation into sections, for example workspace navigation and settings. Combine Spacer and Badge to show counts next to an item.

Workspace
Dashboard
Inbox
12
Reports
Settings
Members
Billing
Integrations

Collapsible groups

Wrap a group with the Collapsible component to let users collapse sections they use less often. Use Sidebar.GroupEndElement for contextual actions like creating a new project, shown on hover.

Dashboard
Inbox
Projects
Website redesign
Mobile app
Q3 marketing

Nested navigation

Nav items can be nested one level deep, for example to show pages inside a project. Wrap the parent NavItem with Collapsible and indent the nested GroupContent.

Dashboard
Projects
Website redesign
Mobile app
Q3 marketing
Settings

Hover actions

Use Sidebar.NavButtonEndElement to add secondary actions to a nav item, like removing an item from favourites. Reveal them on hover with the _parentHover condition to keep the sidebar clean.

Dashboard
Inbox
Favourites

🚀

Product launch

🎨

Design system

📈

Growth experiments

User menu

Use Sidebar.Footer for content that sticks to the bottom of the sidebar, like an account menu with profile and sign out actions.

Dashboard
Inbox
Contacts

Toggling the sidebar

Sidebar.Trigger toggles the sidebar open and closed. Render one in the sidebar header to collapse it and one in your page header to re-open it. The _open condition can be used to hide the trigger while the sidebar is open.

Acme Inc
Dashboard
Inbox
Contacts

Dashboard

Use the toggle in the sidebar header to collapse the sidebar, and the one in the page header to open it again.

Flyout mode

In flyout mode the sidebar stays hidden and flies out over your content when the cursor reaches the edge of the screen, similar to Notion or Linear. Render a Sidebar.FlyoutTrigger to activate it and a Sidebar.Backdrop to close it when the cursor leaves. Flyout mode is only available on desktop, on mobile the sidebar falls back to collapsible mode.

Dashboard
Inbox
Contacts
Move your cursor to the left edge to open the sidebar. It closes again when you move away.

Controlled

Control the open state yourself with the open and onOpenChange props on Sidebar.Provider, for example to persist the state or toggle the sidebar from elsewhere in your app. Alternatively you can use the useSidebar hook inside the provider to access open, setOpen and toggle.

Dashboard
Inbox
Contacts

Dashboard

Props

Provider

PropDefaultDescription
mode'collapsible''collapsible' | 'flyout' — Flyout mode is only available on desktop.
variant'sidebar''sidebar' | 'inset' — Inset renders the main content as a raised panel.
defaultOpentrueThe initial visibility of the sidebar.
openControlled visibility of the sidebar.
onOpenChangeCallback invoked when the visibility changes.
onModeChangeCallback invoked when the mode changes.
PropDefaultDescription
size'md''sm' | 'md' | 'lg' — The size of the nav item.
activefalseSet on NavButton to mark the current page.

Previous

Separator

Next

Skeleton