NavSidebar

NavSidebar

HkNavSidebar is the ready-made navigation band: give it one entry per app route and it renders one row each, marks the row whose route equals the current one, and reports a press as a navigate event with the target route. It is the shortest path from an array of routes to a working sidebar — the rows are NavItems, so the band inherits that row grammar, and the panel around it is Sidebar.

  • When the nav is yours — groups, headers, a footer, an icon rail that collapses — build the rows directly from NavItem inside Sidebar; this component always renders one flat list.
  • The band's routes are compared as plain strings, so it suits a host that owns its routing. A trail of ancestors above the page is Breadcrumb's job.
  • Two of its props do not do what their names suggest — collapsed changes nothing in Vue, and the Rust form renders the band without the panel. Both are documented below rather than left for you to discover.

Import

tsx
1
import { HkNavSidebar } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // NavSidebar, NavSidebarItem
use hikari_components::prelude::*; // rsx!, VNode, EventHandler

The Rust form is a plain function, NavSidebar(NavSidebarProps { … }); Vue's navItems prop is items there. Inside rsx! every prop may be omitted, and an omitted list renders an empty band.

Items, the active route and badges

Each entry is { key, icon, label, route, disabled?, badge? }. icon is a name — one of the twenty keys of the component's own icon table (chart, plug, bot, cpu, zap, folder, radio, monitor, box, link, key, shield, bar, gauge, mic, settings, panels, bell, share, manifest) — not the name of a glyph component; a key outside the table draws no icon but keeps the empty icon cell, so the labels stay aligned.

currentRoute is compared to each entry's route with exact string equality: no prefix match, no trailing-slash normalisation, so /dashboard/ and /dashboard are different routes. A press emits navigate with the pressed entry's route — the band never changes the active row itself, so the host decides whether the route takes effect.

badge renders a small pill after the label, with the accessible name "‹badge› pending" ("3 pending"). It is skipped when the badge string is empty. In Vue that label text is hard-coded English; the Rust form renders the same text through the translation bundle (components.hk.navSidebar.badgePending, "{badge} pending"), so a host can translate it there.

The panel, and why collapsed does nothing

In Vue the band is mounted inside <HSidebar width="224px">: the panel chrome, the scrolling body and the border are Sidebar's, and this component supplies only the <nav> and its rows. That width is a literal in the component, so the band is always 224px wide inside whatever column the host gives it.

collapsed is declared on this component and then never threaded into the panel — Vue's render passes width and nothing else. The band therefore stays at full width with its labels visible whatever the flag says, and the Rust form keeps the prop for surface parity and reproduces the same render instead of inventing a collapsed layout the Vue form cannot show. To get an icon rail, use Sidebar's own rail (its collapsible / collapsed props), or build the rows yourself.

The Rust form does not render the panel: the crate's Sidebar is still the legacy component, so a mirror of HkSidebar is not available to compose yet. NavSidebar renders exactly the <nav> band Vue nests in the panel and leaves the panel to the host, exporting the width it must use as nav_sidebar_panel_width() ("224px").

The two rows above are identical on purpose: collapsed is inert on both sides.

Icons, and the two vocabularies

Vue resolves each entry's icon key to a lucide component, so the band paints whatever that set carries. The Rust mirror resolves the same twenty keys onto the crate's deliberately small MdiIcon enum: nine are exact counterparts (zap, mic, settings, panels, bell, box, chart, bar, manifest) and the other eleven are the nearest glyph the minimal set has — plug is a two-way arrow, folder an open book, radio a right arrow, monitor a column split, link a branch, key a tag, shield a check circle, share a horizontal expand, and cpu / bot a cube and a chat bubble. An unknown key is a miss on both sides and leaves the icon cell empty. nav_sidebar_icon(key) is the pure mapping if a host needs to place the same glyph elsewhere.

API

Vue

Props

NameTypeDefaultRequired
navItemsArray as PropType<NavItem[]>—✓
currentRouteString—✓
collapsedBooleanfalse—

Emits

EventPayload
navigate—

Rust

Props — NavSidebar

PropTypeDefaultDescription
itemsVec<NavSidebarItem>[]Vue: navItems (required upstream; an empty list renders an empty band).
current_routeString""Vue: currentRoute (required upstream) — the row whose route equals it is the active one.
collapsedboolfalseVue: collapsed — see the header delta: declared upstream and never threaded into the panel, so it changes nothing in the render.
on_navigateOption<EventHandler<String>>NoneThe navigate emit (Vue: emits: ["navigate"], payload route).
classString""Host class for the band (Vue: attribute fallthrough on <nav>).

Accessibility

  • The band is a <nav> landmark. It carries no accessible name of its own on either side, and its rows are buttons rather than links, so "navigate" is a press on a button that then changes the page: assistive technology does not announce it as navigation between pages.
  • The active row is marked visually and with data-active, but not with aria-current — that attribute belongs to NavItem's to branch, which this band does not use. The current route is therefore a colour and weight change only.
  • A disabled entry renders a natively disabled button, so it is skipped by the Tab order and announced as disabled. (In NavItem's anchor branches the same flag keeps the row focusable.)
  • The badge pill carries no aria-hidden; its accessible name ("3 pending") comes from aria-label on the pill, so the count is read out after the label rather than as part of it.
  • The Rust form contributes only the <nav> and its rows: whatever landmark the host wraps around it, and the panel's own scrolling and focus behaviour, are the host's responsibility.

Related components

  • NavItem — the single row this band is built from, with its accordion group and anchor forms.
  • Sidebar — the panel and the icon rail the Vue band is mounted in.
  • SidebarRailToggle — the circular control that collapses a panel to its icon rail.
  • Breadcrumb — the trail above the page, for hierarchy rather than app navigation.
  • ModalBreadcrumb — the window-chain strip, when the navigation in question is the stack of open overlays.