SidebarLayout
Two-column layout with resizable and collapsible sidebar.
Import
Basic Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sidebar* | React.ReactNode | — | Content to render in the sidebar panel |
children* | React.ReactNode | — | Main content area |
defaultSidebarWidth | number | 200 | Default sidebar width in pixels |
minSidebarWidth | number | 100 | Minimum sidebar width in pixels |
maxSidebarWidth | number | 500 | Maximum sidebar width in pixels |
showHandle | boolean | false | Whether to show the resize handle |
collapsible | boolean | false | Whether the sidebar can be collapsed |
defaultCollapsed | boolean | false | Whether the sidebar starts collapsed |
side | 'left' | 'right' | 'left' | Which side the sidebar appears on |
className | string | — | Additional CSS class names |
Variants
Resizable Sidebar
Add a drag handle to allow users to resize the sidebar:
Collapsible Sidebar
Allow users to collapse and expand the sidebar:
Right Sidebar
Position the sidebar on the right side:
Full-Featured Layout
Combine resizing and collapsing capabilities:
Accessibility
- Resize handle has proper ARIA attributes (
role="separator",aria-orientation,aria-valuenow) - Keyboard support for resizing (Arrow keys)
- Collapse button has
aria-labelandaria-expandedattributes - Collapsed sidebar has
aria-hiddenattribute
Styling
SidebarLayout uses CSS custom properties for theming:
| Variable | Description |
|---|---|
--theme-border | Divider and handle border color |
--theme-background | Sidebar background color |
--theme-foreground | Text and icon color |