Sidebar nav
stable 2.7 kB<hk-sidebar-nav>A navigation rail that collapses to icons without losing its landmarks, so muscle memory survives the collapse.
#nav#tree
In the package
npm i hellskitchen-ui Import hk-sidebar-nav and use it directly. Live demo
Running in this page — interact with it.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| sections | HkSidebarNavSection[] | [] | Sections, each with an id, label, icon (SVG path data) and optional children. |
| collapsed | boolean | false | Collapses to the icon rail. Two-way bindable. |
| active | string | '' | Active section or child id. Two-way bindable. |
| overlayBelow | string | 'lg' | Breakpoint (sm, md, lg, xl, 2xl or a CSS length) under which the rail overlays instead of pushing content. |
Outputs
activeChangeEventEmitter<string>Emits on navigation.
Keyboard
- Tab Moves through items
- Enter Navigates
- Escape Closes the overlay rail on small screens
Theming
Component tokens, each falling back to a global one:
| Property | Default | Controls |
|---|---|---|
| --hk-nav-width | 13rem | Expanded width. |
| --hk-nav-rail | 3.25rem | Collapsed width. |
| --hk-nav-active-bg | #fef2f2 | Active item fill. |
Accessibility
- Rendered as a nav landmark with an accessible name, so it can be jumped to directly.
- Icons keep their labels when collapsed via aria-label — the rail is never icon-only to a screen reader.
- The active item is marked aria-current, not just tinted.