Sidebar
Composable, collapsible app sidebar.
Import
import { Sidebar, SidebarProvider, SidebarTrigger, SidebarContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton } from "@cronus-ui/ui";
npx cronus-ui add sidebar
Examples
.cronus
The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.
default.cronus
app "audit-fixtures" {
port 5176
}
style {
preset aurora
theme dark
}
component SidebarDefault layout:inline style:sidebar {
aria-label:"Sidebar"
label "Sidebar"
text "Home"
text "Inbox"
}
page "/audit/sidebar/default" type:custom {
use SidebarDefault
}
API Reference
Generated from the component's exported types.
SidebarProviderProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
defaultOpen | boolean | true | Default desktop open state when uncontrolled. |
open | boolean | — | Controlled desktop open state. |
onOpenChange | (open: boolean) => void | — | Called when the open state changes. |
enableKeyboardShortcut | boolean | true | Enable the Ctrl/Cmd+B toggle shortcut. |
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
side | "left" | "right" | "left" | — |
variant | "sidebar" | "floating" | "inset" | "sidebar" | Visual variant. |
collapsible | "offcanvas" | "icon" | "none" | "icon" | — |
aria-label | string | — | Accessible label for the navigation landmark. |
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarTriggerProps
Extends ButtonHTMLAttributes<HTMLButtonElement>
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Render through a custom element while keeping the toggle behavior. |
type | string | — | Native type of the underlying element. |
disabled | boolean | — | Disables pointer and keyboard interaction. |
onClick | (event: MouseEvent) => void | — | Click handler. |
children | ReactNode | — | Contents of the component. |
className | string | — | Additional class names merged onto the root. |
SidebarGroupLabelProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Render as the child element via Slot. |
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarMenuButtonProps
Extends ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof sidebarMenuButtonVariants>
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Render as the child element via Slot. |
isActive | boolean | false | — |
tooltip | ReactNode | ComponentPropsWithoutRef<typeof TooltipContent> | — | Tooltip content shown only when the sidebar is collapsed to icons on desktop. Accepts a string or full `TooltipContent` props. |
size | "sm" | "md" | "lg" | "md" | One of "sm" | "md" | "lg". |
children | ReactNode | — | Contents of the component. |
className | string | — | Additional class names merged onto the root. |
type | string | — | Native type of the underlying element. |
disabled | boolean | — | Disables pointer and keyboard interaction. |
onClick | (event: MouseEvent) => void | — | Click handler. |
SidebarMenuSubButtonProps
Extends ButtonHTMLAttributes<HTMLButtonElement>
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Render as the child element via Slot. |
isActive | boolean | false | — |
size | "sm" | "md" | "md" | Control size. |
type | string | — | Native type of the underlying element. |
disabled | boolean | — | Disables pointer and keyboard interaction. |
onClick | (event: MouseEvent) => void | — | Click handler. |
children | ReactNode | — | Contents of the component. |
className | string | — | Additional class names merged onto the root. |
SidebarRailProps
Extends ButtonHTMLAttributes<HTMLButtonElement>
| Prop | Type | Default | Description |
|---|---|---|---|
type | string | — | Native type of the underlying element. |
disabled | boolean | — | Disables pointer and keyboard interaction. |
onClick | (event: MouseEvent) => void | — | Click handler. |
children | ReactNode | — | Contents of the component. |
className | string | — | Additional class names merged onto the root. |
SidebarInsetProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarHeaderProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarFooterProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarContentProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarSeparatorProps
Extends ComponentPropsWithoutRef<typeof Separator>
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | — | Render as the child element via Slot. |
children | ReactNode | — | Contents of the component. |
className | string | — | Additional class names merged onto the root. |
SidebarGroupProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarGroupContentProps
Extends HTMLAttributes<HTMLDivElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarMenuProps
Extends HTMLAttributes<HTMLUListElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarMenuItemProps
Extends HTMLAttributes<HTMLLIElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarMenuSubProps
Extends HTMLAttributes<HTMLUListElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |
SidebarMenuSubItemProps
Extends HTMLAttributes<HTMLLIElement>
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional class names merged onto the root. |
children | ReactNode | — | Contents of the component. |
id | string | — | DOM id of the root element. |