Toggle Sidebar B
header.lightDarkMode D

Sidebar

Full sidebar layout primitive — handles desktop/mobile collapse, off-canvas mode, icon-only mode, and a persistent rail for resizing. The UI Library itself uses this for its left nav.

Anatomy

Import all parts and piece them together.

vue
<script setup>
import {
  Sidebar,
  SidebarContent,
  SidebarFooter,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarHeader,
  SidebarInset,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarProvider,
  SidebarRail,
} from "@/components/ui/sidebar";
</script>

<template>
  <SidebarProvider>
    <Sidebar>
      <SidebarHeader />
      <SidebarContent>
        <SidebarGroup>
          <SidebarGroupLabel />
          <SidebarGroupContent>
            <SidebarMenu>
              <SidebarMenuItem>
                <SidebarMenuButton />
              </SidebarMenuItem>
            </SidebarMenu>
          </SidebarGroupContent>
        </SidebarGroup>
      </SidebarContent>
      <SidebarFooter />
      <SidebarRail />
    </Sidebar>
    <SidebarInset />
  </SidebarProvider>
</template>

Default

Minimal layout: provider + Sidebar with nav + SidebarInset for the page content.

Acme Inc
Workspace
Page content

API Reference

Props, events, and slots for each sub-component.

SidebarProvider

Props

PropTypeDefaultDescription
defaultOpenbooleantrueInitial open state on desktop.
openbooleanOpen state. Supports v-model:open.
styleobjectSet CSS vars like --sidebar-width.

Events

EventDescription
update:openFires when the sidebar opens or collapses. Enables v-model:open.

Sidebar

Props

PropTypeDefaultDescription
side"left" | "right""left"Edge the sidebar attaches to.
variant"sidebar" | "floating" | "inset""sidebar"Visual variant.
collapsible"offcanvas" | "icon" | "none""offcanvas"How the sidebar collapses on mobile.

SidebarTrigger / SidebarRail

Props

PropTypeDefaultDescription
classstringTrigger is the toggle button; Rail is the draggable edge that also toggles on click.

SidebarMenuButton

Props

PropTypeDefaultDescription
isActivebooleanfalseMark the current nav item.
tooltipstring | ComponentShown when the sidebar is collapsed to icon mode.
variant"default" | "outline""default"Visual style.
size"default" | "sm" | "lg""default"Button height.
asChildbooleanfalseRender into a child element such as NuxtLink.

SidebarMenu / SidebarMenuItem / SidebarMenuAction / SidebarMenuBadge

Props

PropTypeDefaultDescription
classstringMenu is the list; Item is one row; Action is a trailing button; Badge shows a count.

SidebarMenuSub / SidebarMenuSubItem / SidebarMenuSubButton

Props

PropTypeDefaultDescription
isActivebooleanfalse(SubButton) Mark the active nested item. Sub renders the indented child list.

SidebarHeader / SidebarContent / SidebarFooter / SidebarGroup / SidebarGroupLabel / SidebarGroupContent / SidebarGroupAction / SidebarInset / SidebarSeparator / SidebarInput / SidebarMenuSkeleton

Props

PropTypeDefaultDescription
classstringStructural wrappers for the sidebar regions. SidebarInset holds the page content beside the sidebar.

Accessibility

Keyboard shortcuts and ARIA behavior.

Keyboard

ShortcutDescription
TabMoves focus through the menu links and buttons.
Shift+TabMoves focus to the previous link or button.
EnterActivates the focused SidebarMenuButton.
SpaceActivates the focused SidebarMenuButton.
  • Ctrl/Cmd+B toggles the sidebar via the SIDEBAR_KEYBOARD_SHORTCUT global shortcut.
  • Supports collapsible offcanvas and icon modes; the SidebarTrigger carries an aria-label for its toggle action.