Sidebar API

API reference for the Sidebar component: its props with their token values and defaults, the styled-system prop groups, and forwarded HTML attributes.

Demos

For usage examples, visit the component demo page: Sidebar

Import

import { Sidebar } from '@soroush.tech/design-system/Sidebar'

Props

Also accepts every Flex prop (bg, spacing, layout, ...).

PropTypeDefaultDescription
childrenReactNode-Rail contents - items and any other nodes.
isOpenboolean-Whether item labels are shown. Controlled.
anchor'left' | 'right''left'Screen edge the rail hugs - labels render away from it.
variant'text' | 'outlined' | 'plain''text'Default variant for every item - an item's own variant wins.
expandedWidthstring'14rem'Rail width while open.
collapsedWidthstring'3.5rem'Rail width while collapsed (icons only).
hasPanelbooleanfalseRender the selected item's children in a second column.
panelWidthstring'18rem'Width of the panel column. Only meaningful with hasPanel.
panelPropsOmit<FlexProps, 'children'|'id'> & { as?: ElementType }-Props for the panel column - any Flex prop, plus as.
aria-labelstring-Required accessible name of the <nav> landmark.

Theming

SlotElement
rootThe <nav> landmark wrapping the rail and, when shown, the panel.
railThe animating icon column.
panelThe <section> column shown by hasPanel.

The root holds no width of its own - it is sized by its contents, which is what lets bg and the other Flex props cover the panel as well as the rail rather than stopping at the rail's edge. The width animation lives on rail, runs 200ms, and honors prefers-reduced-motion.

Customize via theme.components.Sidebar.styleOverrides.

Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.