Side Nav
Collapsible product navigation that integrates with AppShell compact mode.
SideNav is a compound product-navigation layout with collapsible sections, active-page state, and a compact rail. Its surface uses --sidebar (#eceff1 in light mode and #0f0f0f in dark mode), falling back to --background-default. Collapsed item labels appear in tooltips by default. Inside AppShell, its toggle also drives the mobile and tablet-portrait sheet.
Import
Section titled “Import”import { SideNav } from "@zentara-co/zenos-ui";Anatomy
Section titled “Anatomy”SideNav├── SideNav.Header│ └── SideNav.Toggle├── SideNav.Content│ └── SideNav.Section│ └── SideNav.Item└── SideNav.FooterPolymorphism
Section titled “Polymorphism”SideNav and its structural parts use the shared layout as API. The selected element’s native props and ref type are preserved.
<SideNav as="nav" aria-label="Workspace"> <SideNav.Header as="header">Zenos</SideNav.Header> <SideNav.Content as="ul"> <SideNav.Section as="li" label="Workspace"> <SideNav.Item as="a" href="/overview"> Overview </SideNav.Item> </SideNav.Section> </SideNav.Content> <SideNav.Footer as="footer">Help</SideNav.Footer></SideNav>Collapsed rail
Section titled “Collapsed rail”Supply collapsedContent to Header so the rail retains a useful brand or expansion control. Labels remain available to assistive technology when visually collapsed, while item icons stay visible.
Item tooltips are enabled by default and appear only while the rail is collapsed. Disable them for the entire navigation when another nearby surface already identifies each item:
<SideNav tooltip={false} aria-label="Workspace"> {/* ... */}</SideNav>Controlled state
Section titled “Controlled state”Outside AppShell, use collapsed and onCollapsedChange to coordinate the rail with application state. defaultCollapsed provides the uncontrolled form.
Links and active state
Section titled “Links and active state”SideNav.Item renders a button by default. Use as="a" with href for navigation, or another compatible semantic element. Set active only for the current destination; it adds aria-current="page" as well as the visual indicator.
Sections are expanded by default. Their open, defaultOpen, and onOpenChange props support controlled and uncontrolled disclosure state independently from the rail.
SideNav SideNav.Header SideNav.Content SideNav.Section SideNav.Item SideNav.Footer SideNav.Toggle
API
| Prop | Type | Default | Description |
|---|---|---|---|
collapsed | boolean | — | Controlled rail state outside AppShell. |
defaultCollapsed | boolean | false | Initial uncontrolled rail state. |
onCollapsedChange | (collapsed: boolean) => void | — | Runs when rail state changes. |
tooltip | boolean | true | Shows item-label tooltips while the navigation is collapsed. |
as | ElementType | nav | Rendered element for Root, Header, Content, Section, Footer, and Item. Native props and ref types follow the selected element. |
active | boolean | false | Marks SideNav.Item as the current page. |
SideNav.Item icon | ReactNode | — | Visual icon retained when the navigation is collapsed. |
SideNav.Header collapsedContent | ReactNode | — | Header content rendered in rail mode. |
SideNav.Section label | ReactNode | — | Accessible section heading and disclosure trigger. |
SideNav.Section open / defaultOpen | boolean | defaultOpen: true | Controlled or initial section disclosure state. |
SideNav.Section onOpenChange | (open: boolean) => void | — | Runs when a section opens or closes. |
SideNav.Toggle collapseLabel / expandLabel | string | — | Accessible labels for both toggle states. |
native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”Give each SideNav a concise aria-label. Provide a text equivalent for every icon through the item label; the same label supplies the collapsed tooltip. Tooltips also open on keyboard focus. Keep Toggle’s default accessible labels unless the surrounding product language needs a clearer phrase. Section buttons expose their expanded state and remove collapsed content from keyboard interaction.