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

NameTypeDefaultDescription
sectionsHkSidebarNavSection[][]Sections, each with an id, label, icon (SVG path data) and optional children.
collapsedbooleanfalseCollapses to the icon rail. Two-way bindable.
activestring''Active section or child id. Two-way bindable.
overlayBelowstring'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:

PropertyDefaultControls
--hk-nav-width13remExpanded width.
--hk-nav-rail3.25remCollapsed width.
--hk-nav-active-bg#fef2f2Active 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.

More in Navigation