Sidebar
A collapsible side navigation panel component.
Usage
Sidebar Props
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
onOpenChange | ((open: boolean) => void) | - |
defaultOpen | boolean | - |
collapsible | boolean | undefined |
position | "left" | "right" | "left" |
hideCollapsedItemTooltip | boolean | false |
tooltipMessage | ReactNode | - |
Sidebar.Header Props
The header section is a container component that accepts all div props. It's commonly used to create a header with an icon and title.
Sidebar.Group Props
| Prop | Type | Default |
|---|---|---|
label | string | - |
leadingIcon | ReactNode | - |
children | ReactNode | - |
Sidebar.Item Props
Note: leadingIcon is optional and will show a fallback avatar only in collapsed state. You can pass <></> to render truly nothing.
| Prop | Type | Default |
|---|---|---|
leadingIcon | ReactNode | - |
href | string | - |
active | boolean | - |
disabled | boolean | - |
children | ReactNode | - |
as | ReactElement<any, string | JSXElementConstructor<any>> | "<a />" |
classNames | { root?: string | undefined; leadingIcon?: string | undefined; text?: string | undefined; } | - |
Examples
Position
The Sidebar can be positioned on either the left or right side of the screen.
State
The Sidebar supports expanded and collapsed states with smooth transitions.
The data-collapse-hidden attribute can be used to conditionally hide elements when the sidebar is collapsed.
Custom Tooltip Message
You can customize the tooltip message that appears when hovering over the collapse/expand handle using the tooltipMessage prop.
You can use Sidebar as a controlled component to conditionally render different tooltip messages.
Accessibility
The Sidebar implements the following accessibility features:
-
Proper ARIA roles and attributes
role="navigation"for the main sidebarrole="banner"for the headerrole="menuitem"for navigation itemsaria-expandedto indicate sidebar statearia-current="page"for active itemsaria-disabled="true"for disabled items
-
Keyboard navigation support
- Enter/Space to toggle sidebar expansion
- Tab navigation through interactive elements
-
Screen reader support
- Meaningful labels for all interactive elements
- Hidden decorative elements
- Clear state indicators