Skip to content

Sidebar

A composable, collapsible application sidebar.

Installation

pnpm dlx shadcn@latest add @frontal-labs/sidebar

Usage

import {
  Sidebar,
  SidebarContent,
  SidebarInset,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarProvider,
  SidebarTrigger,
} from "@/components/ui/sidebar";
<SidebarProvider>
  <Sidebar collapsible="icon">
    <SidebarContent>
      <SidebarMenu>
        <SidebarMenuItem>
          <SidebarMenuButton isActive>Dashboard</SidebarMenuButton>
        </SidebarMenuItem>
      </SidebarMenu>
    </SidebarContent>
  </Sidebar>
  <SidebarInset>
    <SidebarTrigger />
  </SidebarInset>
</SidebarProvider>

API Reference

SidebarProvider

Wraps the layout and owns the open state. It persists the state to a cookie and switches to a sheet below the md breakpoint.

The sidebar itself.

useSidebar

Hook exposing state, open, setOpen, openMobile, setOpenMobile, isMobile and toggleSidebar. Must be called inside a SidebarProvider.

SidebarTrigger

Button that toggles the sidebar.

SidebarRail

Thin draggable strip along the sidebar edge that also toggles it.

SidebarInset

The main content area beside the sidebar.

SidebarHeader

Sticky area at the top.

SidebarFooter

Sticky area at the bottom.

SidebarContent

The scrollable middle region.

SidebarSeparator

A dividing line.

SidebarInput

An input styled for the sidebar, typically for search.

SidebarGroup

A titled section within the content.

SidebarGroupLabel

The heading for a group.

SidebarGroupAction

An action button aligned to the group heading.

SidebarGroupContent

Wraps the body of a group.

SidebarMenu

A list of navigation items.

SidebarMenuItem

A single row in the menu.

SidebarMenuButton

The interactive element in a row. Accepts isActive, variant, size and tooltip — the tooltip only shows once the sidebar is collapsed to icons.

SidebarMenuAction

A secondary action shown on the trailing edge of a row.

SidebarMenuBadge

A count or status badge on a row.

SidebarMenuSkeleton

Placeholder row for loading states.

SidebarMenuSub

A nested list under a row.

SidebarMenuSubItem

A row within SidebarMenuSub.

SidebarMenuSubButton

The interactive element in a nested row.

Examples

Badges and Submenus