shadcn.io is an independent project built on shadcn/ui
On this page9 sections
A sidebar holds an app's main navigation in a rail down the side of the page: groups of links, a workspace switcher at the top, the account menu at the bottom. It folds to a strip of icons or slides away, and the page takes back the room.
Reach for it when a product has more destinations than fit across a header. A site with a handful of top-level pages is better served by a Navigation Menu, and a phone app with four or five sections by Bottom Navigation.
Installation
Anatomy

Usage
<script setup lang="ts">
import {
defineComponent, h, shallowRef, unref, type Component,
} from "vue"
import {
AudioWaveformIcon, BadgeCheckIcon, BellIcon, BookOpenIcon, BotIcon,
ChevronRightIcon, ChevronsUpDownIcon, CommandIcon, CreditCardIcon,
FolderIcon, ForwardIcon, FrameIcon, GalleryVerticalEndIcon,
LogOutIcon, MapIcon, MoreHorizontalIcon, PieChartIcon, PlusIcon,
Settings2Icon, SparklesIcon, SquareTerminalIcon, Trash2Icon,
} from "lucide-vue-next"
import {
Avatar, AvatarFallback, AvatarImage,
} from "@/components/ui/avatar"
import {
Collapsible, CollapsibleContent, CollapsibleTrigger,
} from "@/components/ui/collapsible"
import {
Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuSeparator,
MenuShortcut, MenuTrigger,
} from "@/components/ui/menu"
import {
Sidebar, SidebarContent, SidebarFooter, SidebarGroup,
SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu,
SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub,
SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider,
SidebarRail, SidebarTrigger, useSidebar,
} from "@/components/ui/sidebar"
// React's state setter argument: the next value, or a function of the last.
type SetStateAction<T> = T | ((value: T) => T)
const TeamMenuItem = defineComponent(
(props: {
index: number;
onSelect: (team: Team) => void;
team: Team;
}) => {
return () => {
const { index, onSelect, team } = props;
const handleClick = () => {
onSelect(team);
}
return (
h(MenuItem as never, { class: "gap-2 p-2", onSelect: handleClick, value: team.name }, () => [h("div" as never, { class: "flex size-6 items-center justify-center rounded-md border" }, h(team.logo as never, { "aria-hidden": "true", class: "size-3.5 shrink-0" })), team.name, h(MenuShortcut as never, {}, () => ["⌘", index + 1])])
);
}
},
{ name: "TeamMenuItem", inheritAttrs: false, props: ["index", "onSelect", "team"] }
)
const TeamSwitcher = defineComponent(
(props: { teams: Team[] }) => {
const { teams } = props;
const sidebarApi = useSidebar()
const activeTeam = shallowRef(teams[0])
const setActiveTeam = (next: SetStateAction<typeof activeTeam.value>) => {
activeTeam.value = typeof next === "function" ? next(activeTeam.value) : next
}
const handleSelectTeam = (team: Team) => {
setActiveTeam(team);
}
return () => {
const { teams } = props;
const { isMobile } = unref(sidebarApi)
if (!activeTeam.value) {
return null;
}
return (
h(SidebarMenu as never, {}, () => h(SidebarMenuItem as never, {}, () => h(Menu as never, { positioning: {
gutter: 4,
placement: isMobile ? "bottom-start" : "right-start",
} }, () => [h(MenuTrigger as never, null, { render: ({ props }: { props: Record<string, unknown> }) => h(SidebarMenuButton as never, { ...props, class: "data-open:bg-sidebar-accent data-open:text-sidebar-accent-foreground", size: "lg" }, () => [h("div" as never, { class: "flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground" }, h(activeTeam.value.logo as never, { "aria-hidden": "true", class: "size-4" })), h("div" as never, { class: "grid flex-1 text-start text-sm leading-tight" }, [h("span" as never, { class: "truncate font-medium" }, [activeTeam.value.name]), h("span" as never, { class: "truncate text-xs" }, [activeTeam.value.plan])]), h(ChevronsUpDownIcon as never, { "aria-hidden": "true", class: "ms-auto" })]) }), h(MenuContent as never, { class: "w-(--reference-width) min-w-56 rounded-lg" }, () => [h(MenuGroup as never, {}, () => [h(MenuGroupLabel as never, { class: "text-muted-foreground text-xs" }, () => "Teams"), teams.map((team, index) => (
h(TeamMenuItem as never, { index: index, key: team.name, onSelect: handleSelectTeam, team: team })
))]), h(MenuSeparator as never, {}), h(MenuGroup as never, {}, () => h(MenuItem as never, { class: "gap-2 p-2", value: "add-team" }, () => [h("div" as never, { class: "flex size-6 items-center justify-center rounded-md border bg-transparent" }, h(PlusIcon as never, { "aria-hidden": "true", class: "size-4" })), h("div" as never, { class: "font-medium text-muted-foreground" }, "Add team")]))])])))
);
}
},
{ name: "TeamSwitcher", inheritAttrs: false, props: ["teams"] }
)
const NavMain = defineComponent(
(props: {
items: {
icon?: (Component | string);
isActive?: boolean;
items?: { title: string; url: string }[];
title: string;
url: string;
}[];
}) => {
return () => {
const { items } = props;
return (
h(SidebarGroup as never, {}, () => [h(SidebarGroupLabel as never, {}, () => "Platform"), h(SidebarMenu as never, {}, () => [items.map((item) => (
h(Collapsible as never, { class: "group/collapsible", defaultOpen: item.isActive, key: item.title, lazyMount: false, unmountOnExit: false }, { render: ({ props }: { props: Record<string, unknown> }) => h(SidebarMenuItem as never, { ...props }, () => [h(CollapsibleTrigger as never, null, { render: ({ props }: { props: Record<string, unknown> }) => h(SidebarMenuButton as never, { ...props, tooltip: item.title }, () => [item.icon ? h(item.icon as never, { "aria-hidden": "true" }) : null, h("span" as never, {}, [item.title]), h(ChevronRightIcon as never, { "aria-hidden": "true", class: "ms-auto transition-transform duration-200 group-data-open/collapsible:rotate-90" })]) }), h(CollapsibleContent as never, {}, () => h(SidebarMenuSub as never, {}, () => [item.items?.map((subItem) => (
h(SidebarMenuSubItem as never, { key: subItem.title }, () => h(SidebarMenuSubButton as never, { href: subItem.url }, () => h("span" as never, {}, [subItem.title])))
))]))]) })
))])])
);
}
},
{ name: "NavMain", inheritAttrs: false, props: ["items"] }
)
const NavProjects = defineComponent(
(props: {
projects: { icon: (Component | string); name: string; url: string }[];
}) => {
const sidebarApi = useSidebar()
return () => {
const { projects } = props;
const { isMobile } = unref(sidebarApi)
return (
h(SidebarGroup as never, { class: "group-data-[collapsible=icon]:hidden" }, () => [h(SidebarGroupLabel as never, {}, () => "Projects"), h(SidebarMenu as never, {}, () => [projects.map((item) => (
h(SidebarMenuItem as never, { key: item.name }, () => [h(SidebarMenuButton as never, null, { render: ({ props }: { props: Record<string, unknown> }) => h("a" as never, { ...props, href: item.url }, [h(item.icon as never, { "aria-hidden": "true" }), h("span" as never, {}, [item.name])]) }), h(Menu as never, { positioning: {
placement: isMobile ? "bottom-end" : "right-start",
} }, () => [h(MenuTrigger as never, null, { render: ({ props }: { props: Record<string, unknown> }) => h(SidebarMenuAction as never, { ...props, showOnHover: true }, () => [h(MoreHorizontalIcon as never, { "aria-hidden": "true" }), h("span" as never, { class: "sr-only" }, "More")]) }), h(MenuContent as never, { class: "w-48 rounded-lg" }, () => [h(MenuItem as never, { value: `${item.name}-view` }, () => [h(FolderIcon as never, { "aria-hidden": "true", class: "text-muted-foreground" }), h("span" as never, {}, "View Project")]), h(MenuItem as never, { value: `${item.name}-share` }, () => [h(ForwardIcon as never, { "aria-hidden": "true", class: "text-muted-foreground" }), h("span" as never, {}, "Share Project")]), h(MenuSeparator as never, {}), h(MenuItem as never, { value: `${item.name}-delete` }, () => [h(Trash2Icon as never, { "aria-hidden": "true", class: "text-muted-foreground" }), h("span" as never, {}, "Delete Project")])])])])
)), h(SidebarMenuItem as never, {}, () => h(SidebarMenuButton as never, { class: "text-sidebar-foreground/70" }, () => [h(MoreHorizontalIcon as never, { "aria-hidden": "true", class: "text-sidebar-foreground/70" }), h("span" as never, {}, "More")]))])])
);
}
},
{ name: "NavProjects", inheritAttrs: false, props: ["projects"] }
)
const NavUser = defineComponent(
(props: {
user: { avatar: string; email: string; name: string };
}) => {
const sidebarApi = useSidebar()
return () => {
const { user } = props;
const { isMobile } = unref(sidebarApi)
return (
h(SidebarMenu as never, {}, () => h(SidebarMenuItem as never, {}, () => h(Menu as never, { positioning: {
gutter: 4,
placement: isMobile ? "bottom-end" : "right-end",
} }, () => [h(MenuTrigger as never, null, { render: ({ props }: { props: Record<string, unknown> }) => h(SidebarMenuButton as never, { ...props, class: "data-open:bg-sidebar-accent data-open:text-sidebar-accent-foreground", size: "lg" }, () => [h(Avatar as never, { class: "size-8 rounded-lg" }, () => [h(AvatarImage as never, { alt: user.name, height: 32, src: user.avatar, width: 32 }), h(AvatarFallback as never, { class: "rounded-lg" }, () => "CN")]), h("div" as never, { class: "grid flex-1 text-start text-sm leading-tight" }, [h("span" as never, { class: "truncate font-medium" }, [user.name]), h("span" as never, { class: "truncate text-xs" }, [user.email])]), h(ChevronsUpDownIcon as never, { "aria-hidden": "true", class: "ms-auto size-4" })]) }), h(MenuContent as never, { class: "w-(--reference-width) min-w-56 rounded-lg" }, () => [h(MenuGroup as never, {}, () => h(MenuGroupLabel as never, { class: "p-0 font-normal" }, () => h("div" as never, { class: "flex items-center gap-2 px-1 py-1.5 text-start text-sm" }, [h(Avatar as never, { class: "size-8 rounded-lg" }, () => [h(AvatarImage as never, { alt: user.name, height: 32, src: user.avatar, width: 32 }), h(AvatarFallback as never, { class: "rounded-lg" }, () => "CN")]), h("div" as never, { class: "grid flex-1 text-start text-sm leading-tight" }, [h("span" as never, { class: "truncate font-medium" }, [user.name]), h("span" as never, { class: "truncate text-xs" }, [user.email])])]))), h(MenuSeparator as never, {}), h(MenuGroup as never, {}, () => h(MenuItem as never, { value: "upgrade" }, () => [h(SparklesIcon as never, { "aria-hidden": "true" }), "Upgrade to Pro"])), h(MenuSeparator as never, {}), h(MenuGroup as never, {}, () => [h(MenuItem as never, { value: "account" }, () => [h(BadgeCheckIcon as never, { "aria-hidden": "true" }), "Account"]), h(MenuItem as never, { value: "billing" }, () => [h(CreditCardIcon as never, { "aria-hidden": "true" }), "Billing"]), h(MenuItem as never, { value: "notifications" }, () => [h(BellIcon as never, { "aria-hidden": "true" }), "Notifications"])]), h(MenuSeparator as never, {}), h(MenuGroup as never, {}, () => h(MenuItem as never, { value: "logout" }, () => [h(LogOutIcon as never, { "aria-hidden": "true" }), "Log out"]))])])))
);
}
},
{ name: "NavUser", inheritAttrs: false, props: ["user"] }
)
const data = {
navMain: [
{
icon: SquareTerminalIcon,
isActive: true,
items: [
{ title: "History", url: "#" },
{ title: "Starred", url: "#" },
{ title: "Settings", url: "#" },
],
title: "Playground",
url: "#",
},
{
icon: BotIcon,
items: [
{ title: "Genesis", url: "#" },
{ title: "Explorer", url: "#" },
{ title: "Quantum", url: "#" },
],
title: "Models",
url: "#",
},
{
icon: BookOpenIcon,
items: [
{ title: "Introduction", url: "#" },
{ title: "Get Started", url: "#" },
{ title: "Tutorials", url: "#" },
{ title: "Changelog", url: "#" },
],
title: "Documentation",
url: "#",
},
{
icon: Settings2Icon,
items: [
{ title: "General", url: "#" },
{ title: "Team", url: "#" },
{ title: "Billing", url: "#" },
{ title: "Limits", url: "#" },
],
title: "Settings",
url: "#",
},
],
projects: [
{ icon: FrameIcon, name: "Design Engineering", url: "#" },
{ icon: PieChartIcon, name: "Sales & Marketing", url: "#" },
{ icon: MapIcon, name: "Travel", url: "#" },
],
teams: [
{
logo: GalleryVerticalEndIcon,
name: "Acme Inc",
plan: "Enterprise",
},
{
logo: AudioWaveformIcon,
name: "Acme Corp.",
plan: "Startup",
},
{
logo: CommandIcon,
name: "Evil Corp.",
plan: "Free",
},
],
user: {
avatar: "https://github.com/shadcn.png",
email: "m@example.com",
name: "shadcn",
},
};
type Team = (typeof data.teams)[number];
</script>
<template>
<div class="h-[400px] w-full overflow-hidden rounded-xl border">
<SidebarProvider class="h-full min-h-0" :persist="false" :shortcut="false">
<Sidebar class="h-full" collapsible="icon">
<SidebarHeader><TeamSwitcher :teams="data.teams" /></SidebarHeader>
<SidebarContent>
<NavMain :items="data.navMain" />
<NavProjects :projects="data.projects" />
</SidebarContent>
<SidebarFooter><NavUser :user="data.user" /></SidebarFooter>
<SidebarRail />
</Sidebar>
<SidebarInset>
<header class="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
<div class="flex items-center gap-2 px-4">
<SidebarTrigger class="-ms-1" />
</div>
</header>
</SidebarInset>
</SidebarProvider>
</div>
</template>
Accessibility
Each row is a real link or button, so it sits in the tab order and Enter follows or presses it. SidebarTrigger is a button named Toggle Sidebar. Collapsed to icons, a row keeps its label as its accessible name, and the tooltip you give it shows that label beside the icon. Below 768px the sidebar opens as a modal sheet, which keeps focus inside until Escape or a press outside closes it.
Two things are left to you. The sidebar renders no nav element, so put one with an aria-label around the groups of links. And isActive only changes how a row looks, so add aria-current="page" to the link for the page that is open.
- Tab
- Moves focus to the next link or button in the sidebar, and from the last one on into the page.
- Shift+Tab
- Moves focus to the previous link or button.
- Enter
- Follows the focused link, or presses the focused button, such as a row that opens its sub-items or a menu.
- Space
- Presses the focused button. Links don't respond to it.
- Ctrl+B
- Opens or closes the sidebar from anywhere on the page, a plain text field included, or ⌘ + B on a Mac. In a rich-text editor the keys still make text bold, because the sidebar leaves them to any element with
contenteditableand to a handler that has already used them. SetshortcuttofalseonSidebarProviderto turn it off.
Demos
RTL
The full app shell in Arabic, with dir set to rtl on the frame around it and no direction prop on the sidebar. The rail sits on the right, where an Arabic line starts, floats with a gap around it and collapses to icons, and its menus open to the left, toward the page. Use it as the starting point for an Arabic or Hebrew interface.
FAQ
Should I use a Sidebar or a Navigation Menu for my app?
Use a sidebar for an app people work inside, with destinations in several groups, a workspace or project switcher and an account menu that stay in reach on every screen. It takes a column of the layout and earns it by being there all the time.
A Navigation Menu suits a marketing site or docs with a few top-level sections across the header, each opening a panel of links. Many products use both, the menu on the public site and the sidebar once someone signs in.
How do I open or close the Sidebar from my own state in Vue?
Bind open on SidebarProvider and listen for its open-change event, which receives the next boolean. Set defaultOpen instead when you only need the first state.
Any part under the provider can also call useSidebar, which returns open, setOpen, toggleSidebar and state, either expanded or collapsed. It throws when called outside SidebarProvider, so keep the provider high enough in the layout to cover the header where your own buttons live.
How do I keep the Sidebar open or closed after a page reload?
The provider already writes the desktop state to a cookie named sidebar_state each time it changes, kept for seven days, but it never reads that cookie back. Read it where the page is rendered and pass the result to defaultOpen on SidebarProvider.
Read it on the server if you can, so the first paint already has the right width instead of jumping after hydration. Set persist to false when you would rather keep the state yourself, in local storage or a user setting.
How do I make the Sidebar collapse to icons instead of sliding away?
Set collapsible to icon on Sidebar. The default, offcanvas, slides the whole rail off the edge, icon leaves a 3rem strip with each row's icon showing, and none keeps it open with nothing to toggle.
In the icon strip, give each SidebarMenuButton a tooltip with its label, which shows only while the sidebar is collapsed. Hide a group that means nothing as icons with group-data-[collapsible=icon]:hidden, as the projects list in the demo above does.
How do I put the Sidebar on the right side of the page?
Set placement to right on Sidebar. It names the end of the layout rather than the screen's right edge, so on a right-to-left page the rail moves to the left. The border, the drag handle and the tooltips move with it.
The RTL demo shows the other case, where the page itself reads right to left and the default side already lands on the right.
What happens to the Sidebar on a phone?
Below 768px the rail is replaced by a sheet that slides in over the page from the same side, and SidebarTrigger opens it. useSidebar tells your own parts which layout is showing through isMobile.
The sheet doesn't close when a link inside it is pressed. With client-side routing, call setOpenMobile(false) from useSidebar when a link is clicked, or the menu stays over the new page.
How do I highlight the current page's link in the Sidebar?
Compare each item's address with the router's current path and set isActive on the SidebarMenuButton or SidebarMenuSubButton that matches. It sets data-active, which the accent background keys on. Add aria-current="page" to the same link, since isActive tells a screen reader nothing.
To use your router's link component, render it in the #render slot of SidebarMenuButton and bind the props the slot passes, as the demo does with a plain anchor.
How do I change the Sidebar's width or colors?
Set --sidebar-width and --sidebar-width-icon in the style of SidebarProvider. The provider applies 16rem and 3rem, and what you pass replaces them. Colors come from the sidebar tokens in your CSS, --sidebar, --sidebar-foreground, --sidebar-accent and --sidebar-border among them, so the rail can differ from the page without a class on every part.
Dragging SidebarRail also resizes an open sidebar between 160 and 360 pixels, and dragging it well past the narrow end collapses it. That width isn't saved, so it resets on the next load.
API Reference
Sidebar
<div>
collapsible?"offcanvas" | "icon" | "none"
How it collapses: offcanvas slides it out, icon shrinks it to its * icons, none keeps it open.
- Type
"offcanvas" | "icon" | "none"- Default
"offcanvas"
side?"inline-start" | "inline-end" | "left" | "right"
The edge it's on: inline-start (the default) and inline-end follow the reading direction; left and right are the screen's edges, as in shadcn/ui.
- Type
"inline-start" | "inline-end" | "left" | "right"- Default
"inline-start"
variant?"sidebar" | "floating" | "inset"
The visual style.
- Type
"sidebar" | "floating" | "inset"- Default
"sidebar"
class?string
Merged with the part's classes.
--sidebar-widthstring--sidebar-width-iconstringSidebarContent
<div> data-slot="sidebar-content"
class?string
Merged with the part's classes.
data-sidebar"content"
- Default
"content"
SidebarFooter
<div> data-slot="sidebar-footer"
class?string
Merged with the part's classes.
data-sidebar"footer"
- Default
"footer"
SidebarGroup
<div> data-slot="sidebar-group"
class?string
Merged with the part's classes.
data-sidebar"group"
- Default
"group"
SidebarGroupAction
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
SidebarGroupContent
<div> data-slot="sidebar-group-content"
class?string
Merged with the part's classes.
data-sidebar"group-content"
- Default
"group-content"
SidebarGroupLabel
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
SidebarHeader
<div> data-slot="sidebar-header"
class?string
Merged with the part's classes.
data-sidebar"header"
- Default
"header"
SidebarInput
value?string | number
The value, for a controlled field. A number is written as its text, as a native input does. Two-way with v-model.
- Type
string | number
defaultValue?string | number
The value it starts with. A form reset returns here.
- Type
string | number
controller?InputController
Reads and writes the field from anywhere. Create one with createInputController().
debug?boolean
Logs every state change with its reason to the console, in development builds.
disabled?boolean
Disables the field.
readOnly?boolean
Makes the field read-only.
required?boolean
Makes the field required.
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
@value-change(value: string, details: ChangeDetails<InputValueChangeReason>) → void
Called when the user changes the value: typing ("input-change"), a Clear part ("clear-press"), a form reset ("reset") or a controller ("imperative"). details.cancel() keeps the value as it was.
- Type
(value: string, details: ChangeDetails<InputValueChangeReason>) → void- Parameters
value– stringdetails– ChangeDetails<InputValueChangeReason>- Returns
void
data-sidebar"input"
- Default
"input"
SidebarInset
<main> data-slot="sidebar-inset"
class?string
Merged with the part's classes.
SidebarMenu
<ul> data-slot="sidebar-menu"
class?string
Merged with the part's classes.
data-sidebar"menu"
- Default
"menu"
SidebarMenuAction
showOnHover?boolean
Hides the action until its menu item is hovered or focused, or its menu * is open. Always shown below md.
- Default
false
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
SidebarMenuBadge
<div> data-slot="sidebar-menu-badge"
class?string
Merged with the part's classes.
data-sidebar"menu-badge"
- Default
"menu-badge"
SidebarMenuButton
data-slot="sidebar-menu-action"
isActive?boolean
Whether the button is the current page: highlighted, and data-active.
- Default
false
size?"default" | "lg" | "sm"
The size.
- Type
"default" | "lg" | "sm"- Default
"default"
tooltip?string | React.ComponentProps<typeof TooltipContent>
The tooltip it shows while the sidebar is collapsed to icons: its text, * or the tooltip's props.
- Type
string | React.ComponentProps<typeof TooltipContent>
variant?"default" | "outline"
The visual style.
- Type
"default" | "outline"- Default
"default"
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
data-sidebar"menu-action"
- Default
"menu-action"
SidebarMenuItem
<li> data-slot="sidebar-menu-item"
class?string
Merged with the part's classes.
data-sidebar"menu-item"
- Default
"menu-item"
SidebarMenuSkeleton
<div> data-slot="sidebar-menu-skeleton"
showIcon?boolean
Draws an icon placeholder before the text line.
- Default
false
class?string
Merged with the part's classes.
data-sidebar"menu-skeleton"
- Default
"menu-skeleton"
--skeleton-widthstringSidebarMenuSub
<ul> data-slot="sidebar-menu-sub"
class?string
Merged with the part's classes.
data-sidebar"menu-sub"
- Default
"menu-sub"
SidebarMenuSubButton
isActive?boolean
Whether the button is the current page: highlighted, and data-active.
- Default
false
size?"sm" | "md"
The size.
- Type
"sm" | "md"- Default
"md"
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
SidebarMenuSubItem
<li> data-slot="sidebar-menu-sub-item"
class?string
Merged with the part's classes.
data-sidebar"menu-sub-item"
- Default
"menu-sub-item"
SidebarProvider
open?boolean
Whether it's open. Pair with onOpenChange to control it. Two-way with v-model or v-model:open.
defaultOpen?boolean
Whether it starts open, when you don't control open.
- Default
true
persist?boolean
Persist the desktop open state to a cookie. * * @default true.
- Default
true
shortcut?boolean
Toggle the sidebar with ⌘B / Ctrl+B. * * @default true.
- Default
true
class?string
Merged with the part's classes.
@open-change(open: boolean) → void
Called when it opens or closes.
- Parameters
open– boolean- Returns
void
SidebarRail
<button> data-slot="sidebar-rail"
class?string
Merged with the part's classes.
data-sidebar"rail"
- Default
"rail"
SidebarSeparator
debug?boolean
Logs every state change with its reason to the console, in development builds.
decorative?boolean
Hides the separator from assistive technology with role="none", for a line that's only visual. Leave it off when the separator divides content a screen reader should hear as separate, like groups of menu items.
- Default
false
orientation?SeparatorOrientation
Which way the line runs. A vertical separator divides items in a row.
- Default
"horizontal"
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
data-sidebar"separator"
- Default
"separator"
SidebarTrigger
clickEffect?boolean
Apply a click effect to the button.
- Default
true
debug?boolean
Logs every state change with its reason to the console, in development builds.
disabled?boolean
Stops presses. The button is natively disabled, so it leaves the tab order and its form doesn't submit through it, unless focusableWhenDisabled is set.
- Default
false
focusableWhenDisabled?boolean
Keeps a disabled button in the tab order with aria-disabled instead of the native attribute, so it can hold focus while it becomes disabled and host a tooltip that says why. Presses still do nothing.
- Default
false
isLoading?boolean
Show a loading indicator.
- Default
false
pendingAnnouncement?string
What screen readers hear once the button has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
- Default
"Loading"
pill?boolean
Fully rounded corners.
- Default
false
size?"default" | "icon" | "icon-lg" | "icon-md" | "icon-sm" | "icon-xl" | "icon-xs" | "lg" | "md" | "sm" | "xl" | "xs"
The size.
- Type
"default" | "icon" | "icon-lg" | "icon-md" | "icon-sm" | "icon-xl" | "icon-xs" | "lg" | "md" | "sm" | "xl" | "xs"- Default
"md"
type?"button" | "reset" | "submit"
What a native button does in a form: "submit" submits it and "reset" resets it. Ignored when the button renders as something else.
- Type
"button" | "reset" | "submit"- Default
"button"
variant?"default" | "destructive" | "ghost" | "link" | "outline" | "secondary"
The visual style.
- Type
"default" | "destructive" | "ghost" | "link" | "outline" | "secondary"- Default
"default"
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
@click( event: MouseEvent, details?: ButtonActionDetails ) → unknown
Runs when the button is pressed. Return a Promise to keep it pending
(data-pending) until it settles. details.source says how it was
pressed; a wrapper passing the click on may leave it out.
- Type
( event: MouseEvent, details?: ButtonActionDetails ) → unknown- Parameters
event– React.MouseEvent<HTMLButtonElement>details?– ButtonActionDetails- Returns
unknown











