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
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-react";
import type React from "react";
import { useCallback, useState } from "react";
import {
Avatar, AvatarFallback, AvatarImage,
} from "@/components/ui/avatar";
import {
Collapsible, CollapsibleContent, CollapsibleTrigger,
} from "@/components/ui/collapsible";
import {
DropdownMenu, DropdownMenuContent, DropdownMenuGroup,
DropdownMenuGroupLabel, DropdownMenuItem, DropdownMenuSeparator,
DropdownMenuShortcut, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
Sidebar, SidebarContent, SidebarFooter, SidebarGroup,
SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu,
SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub,
SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider,
SidebarRail, SidebarTrigger, useSidebar,
} from "@/components/ui/sidebar";// This is sample data.
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",
},
};
interface Team {
logo: React.ElementType;
name: string;
plan: string;
}
function TeamMenuItem({
index,
onSelect,
team,
}: {
index: number;
onSelect: (team: Team) => void;
team: Team;
}) {
const handleClick = useCallback(() => {
onSelect(team);
}, [onSelect, team]);
return (
<DropdownMenuItem className="gap-2 p-2" onClick={handleClick}>
<div className="flex size-6 items-center justify-center rounded-md border">
<team.logo aria-hidden="true" className="size-3.5 shrink-0" />
</div>
{team.name}
<DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>
</DropdownMenuItem>
);
}
function TeamSwitcher({ teams }: { teams: Team[] }) {
const { isMobile } = useSidebar();
const [activeTeam, setActiveTeam] = useState(teams[0]);
const handleSelectTeam = useCallback((team: Team) => {
setActiveTeam(team);
}, []);
if (!activeTeam) {
return null;
}
return (
<SidebarMenu>
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger
render={
<SidebarMenuButton
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
size="lg"
/>
}
>
<div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<activeTeam.logo aria-hidden="true" className="size-4" />
</div>
<div className="grid flex-1 text-start text-sm leading-tight">
<span className="truncate font-medium">{activeTeam.name}</span>
<span className="truncate text-xs">{activeTeam.plan}</span>
</div>
<ChevronsUpDownIcon aria-hidden="true" className="ms-auto" />
</DropdownMenuTrigger>
<DropdownMenuContent
align="start"
className="min-w-56 rounded-lg"
side={isMobile ? "bottom" : "right"}
sideOffset={4}
>
<DropdownMenuGroup>
<DropdownMenuGroupLabel className="text-muted-foreground text-xs">
Teams
</DropdownMenuGroupLabel>
{teams.map((team, index) => (
<TeamMenuItem
index={index}
key={team.name}
onSelect={handleSelectTeam}
team={team}
/>
))}
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem className="gap-2 p-2">
<div className="flex size-6 items-center justify-center rounded-md border bg-transparent">
<PlusIcon aria-hidden="true" className="size-4" />
</div>
<div className="font-medium text-muted-foreground">
Add team
</div>
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
</SidebarMenu>
);
}
function NavMain({
items,
}: {
items: {
title: string;
url: string;
icon?: React.ElementType;
isActive?: boolean;
items?: {
title: string;
url: string;
}[];
}[];
}) {
return (
<SidebarGroup>
<SidebarGroupLabel>Platform</SidebarGroupLabel>
<SidebarMenu>
{items.map((item) => (
<Collapsible
className="group/collapsible"
defaultOpen={item.isActive}
key={item.title}
>
<SidebarMenuItem>
<CollapsibleTrigger
render={<SidebarMenuButton tooltip={item.title} />}
>
{item.icon ? <item.icon aria-hidden="true" /> : null}
<span>{item.title}</span>
<ChevronRightIcon
aria-hidden="true"
className="ms-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
/>
</CollapsibleTrigger>
<CollapsibleContent>
<SidebarMenuSub>
{item.items?.map((subItem) => (
<SidebarMenuSubItem key={subItem.title}>
<SidebarMenuSubButton render={<a href={subItem.url} />}>
<span>{subItem.title}</span>
</SidebarMenuSubButton>
</SidebarMenuSubItem>
))}
</SidebarMenuSub>
</CollapsibleContent>
</SidebarMenuItem>
</Collapsible>
))}
</SidebarMenu>
</SidebarGroup>
);
}
function NavProjects({
projects,
}: {
projects: {
name: string;
url: string;
icon: React.ElementType;
}[];
}) {
const { isMobile } = useSidebar();
return (
<SidebarGroup className="group-data-[collapsible=icon]:hidden">
<SidebarGroupLabel>Projects</SidebarGroupLabel>
<SidebarMenu>
{projects.map((item) => (
<SidebarMenuItem key={item.name}>
<SidebarMenuButton render={<a href={item.url} />}>
<item.icon aria-hidden="true" />
<span>{item.name}</span>
</SidebarMenuButton>
<DropdownMenu>
<DropdownMenuTrigger render={<SidebarMenuAction showOnHover />}>
<MoreHorizontalIcon aria-hidden="true" />
<span className="sr-only">More</span>
</DropdownMenuTrigger>
<DropdownMenuContent
align={isMobile ? "end" : "start"}
className="w-48 rounded-lg"
side={isMobile ? "bottom" : "right"}
>
<DropdownMenuItem>
<FolderIcon
aria-hidden="true"
className="text-muted-foreground"
/>
<span>View Project</span>
</DropdownMenuItem>
<DropdownMenuItem>
<ForwardIcon
aria-hidden="true"
className="text-muted-foreground"
/>
<span>Share Project</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>
<Trash2Icon
aria-hidden="true"
className="text-muted-foreground"
/>
<span>Delete Project</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
))}
<SidebarMenuItem>
<SidebarMenuButton className="text-sidebar-foreground/70">
<MoreHorizontalIcon
aria-hidden="true"
className="text-sidebar-foreground/70"
/>
<span>More</span>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroup>
);
}
function NavUser({
user,
}: {
user: {
name: string;
email: string;
avatar: string;
};
}) {
const { isMobile } = useSidebar();
return (
<SidebarMenu>
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger
render={
<SidebarMenuButton
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
size="lg"
/>
}
>
<Avatar className="size-8 rounded-lg">
<AvatarImage alt={user.name} src={user.avatar} />
<AvatarFallback className="rounded-lg">CN</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-start text-sm leading-tight">
<span className="truncate font-medium">{user.name}</span>
<span className="truncate text-xs">{user.email}</span>
</div>
<ChevronsUpDownIcon aria-hidden="true" className="ms-auto size-4" />
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
className="min-w-56 rounded-lg"
side={isMobile ? "bottom" : "right"}
sideOffset={4}
>
<DropdownMenuGroup>
<DropdownMenuGroupLabel className="p-0 font-normal">
<div className="flex items-center gap-2 px-1 py-1.5 text-start text-sm">
<Avatar className="size-8 rounded-lg">
<AvatarImage alt={user.name} src={user.avatar} />
<AvatarFallback className="rounded-lg">CN</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-start text-sm leading-tight">
<span className="truncate font-medium">{user.name}</span>
<span className="truncate text-xs">{user.email}</span>
</div>
</div>
</DropdownMenuGroupLabel>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<SparklesIcon aria-hidden="true" />
Upgrade to Pro
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<BadgeCheckIcon aria-hidden="true" />
Account
</DropdownMenuItem>
<DropdownMenuItem>
<CreditCardIcon aria-hidden="true" />
Billing
</DropdownMenuItem>
<DropdownMenuItem>
<BellIcon aria-hidden="true" />
Notifications
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<LogOutIcon aria-hidden="true" />
Log out
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
</SidebarMenu>
);
}
const SidebarDemo = ({ ...props }: React.ComponentProps<typeof Sidebar>) => (
<div className="relative h-[400px] w-full overflow-hidden rounded-xl border">
<SidebarProvider
className="h-full min-h-0 overflow-hidden"
persist={false}
shortcut={false}
>
<Sidebar className="absolute" collapsible="icon" {...props}>
<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 className="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
<div className="flex items-center gap-2 px-4">
<SidebarTrigger className="-ms-1" />
</div>
</header>
</SidebarInset>
</SidebarProvider>
</div>
);
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 React?
Keep the value in state, pass it as open on SidebarProvider and update it in onOpenChange, 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 side on Sidebar to inline-end, which follows the reading direction: the right edge on an English page, the left on an Arabic one. right and left are fixed screen edges, as in shadcn/ui. The sidebar moves to the end of the row whatever its place in the markup, so the page gives up its room on that side.
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, pass it to SidebarMenuButton through render, 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.
SidebarRail toggles the sidebar when it is clicked and doesn't resize it. A user-resizable rail needs its own drag handler setting --sidebar-width.
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"
className?string
Merged with the part's classes.
--sidebar-widthstring--sidebar-width-iconstringSidebarContent
<div> data-slot="sidebar-content"
className?string
Merged with the part's classes.
data-sidebar"content"
- Default
"content"
SidebarFooter
<div> data-slot="sidebar-footer"
className?string
Merged with the part's classes.
data-sidebar"footer"
- Default
"footer"
SidebarGroup
<div> data-slot="sidebar-group"
className?string
Merged with the part's classes.
data-sidebar"group"
- Default
"group"
SidebarGroupAction
render?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a link, with the part's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
SidebarGroupContent
<div> data-slot="sidebar-group-content"
className?string
Merged with the part's classes.
data-sidebar"group-content"
- Default
"group-content"
SidebarGroupLabel
render?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a link, with the part's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
SidebarHeader
<div> data-slot="sidebar-header"
className?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.
- Type
string | number
defaultValue?string | number
The value it starts with. A form reset returns here.
- Type
string | number
onValueChange?(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
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?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-sidebar"input"
- Default
"input"
SidebarInset
<main> data-slot="sidebar-inset"
className?string
Merged with the part's classes.
SidebarMenu
<ul> data-slot="sidebar-menu"
className?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?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a link, with the part's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
SidebarMenuBadge
<div> data-slot="sidebar-menu-badge"
className?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?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a link, with the part's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
data-sidebar"menu-action"
- Default
"menu-action"
SidebarMenuItem
<li> data-slot="sidebar-menu-item"
className?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
className?string
Merged with the part's classes.
data-sidebar"menu-skeleton"
- Default
"menu-skeleton"
--skeleton-widthstringSidebarMenuSub
<ul> data-slot="sidebar-menu-sub"
className?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?ReactElement | ((props: object, state: object) => ReactElement)
Renders your own element, like a link, with the part's props.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
SidebarMenuSubItem
<li> data-slot="sidebar-menu-sub-item"
className?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.
defaultOpen?boolean
Whether it starts open, when you don't control open.
- Default
true
onOpenChange?(open: boolean) → void
Called when it opens or closes.
- Parameters
open– boolean- Returns
void
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
className?string
Merged with the part's classes.
SidebarRail
<button> data-slot="sidebar-rail"
className?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?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?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
onClick?( event: React.MouseEvent<HTMLButtonElement>, 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: React.MouseEvent<HTMLButtonElement>, details?: ButtonActionDetails ) → unknown- Parameters
event– React.MouseEvent<HTMLButtonElement>details?– ButtonActionDetails- Returns
unknown
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?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.











