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

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
sectionsHkNavSection[][]Sections, each with a label, icon and optional children.
collapsedbooleanfalseCollapses to the icon rail. Two-way bindable.
activestring''Active section id. Two-way bindable.
overlayBelowstring'lg'Breakpoint 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-bgrgb(220 38 38 / 0.10)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.

More in Navigation