App sidebar
The branded primary navigation rail — grouped links with icons, count badges and an active state on the deep brand gradient.
Purpose
The sidebar is the shell's primary navigation: the branded rail on --gradient-deep with the
reversed logo, grouped icon links, and an optional footer slot. Inside
App layout it is composed for you (and hidden below md); pair it
with the Topbar when composing the frame yourself. The
Footer shares the same gradient surface but closes portal pages
rather than framing admin ones.
It is deliberately declarative — you hand it a sections model and it renders the rail. There is
no collapse, no nesting, no state of its own: the active item and badges are declared per link.
Example
The rail fills its container's height. The first section is typically unlabelled — reserve titles for the groups after it.
The navigation model
One flat, two-level shape: sections contain items, and that is the whole hierarchy. Icons are typed HealthMetrics icon names, so a typo fails the build rather than rendering a blank.
import { AppSidebar, type NavSection } from "@healthmetrics/ui/app-sidebar";
const nav: NavSection[] = [
{
// No title — the top group renders without a heading.
items: [
{ label: "Dashboard", href: "/dashboard", icon: "dashboard", active: true },
{ label: "Claims", href: "/claims", icon: "claims", badge: 12 },
{ label: "Guarantee Letters", href: "/guarantee-letters", icon: "guaranteeLetters" },
],
},
{
title: "Admin",
items: [
{ label: "Benefit groups", href: "/benefit-groups", icon: "benefitGroups" },
{ label: "Audit logs", href: "/audit-logs", icon: "auditLogs" },
],
},
];
<AppSidebar sections={nav} />;Router integration
Links default to plain <a> elements — a full page load per click. Supply renderLink with your
router's link component; the sidebar hands it the href, the computed classes, the link content
and aria-current when the item is active.
import Link from "next/link";
<AppSidebar sections={nav} renderLink={(props) => <Link {...props} />} />;Structure
| Property | Value |
|---|---|
| Width | 256px (w-64) |
| Surface | --gradient-deep over a --sidebar fallback fill, --sidebar-foreground text — identical in both themes |
| Brand row | 64px tall (h-16, matches the topbar), reversed logo at 26px |
| Section heading | 11px / Inter 600, uppercase, --sidebar-foreground at 70% |
| Item | 14px / Inter 500, 20px icon, 12px × 8px padding, --radius-md corners |
| Active item | --sidebar-accent fill, icon tinted --sidebar-primary |
| Badge | --sidebar-primary pill, 11px / Inter 600 |
| Focus | 2px --sidebar-ring |
| Footer slot | 1px --sidebar-border top rule, 12px padding |
Best practices
Do
- Keep the top group unlabelled for the primary destinations; title the groups after it.
- Mark exactly one item
active, matching the current route. - Reserve
badgefor genuine counts — unread items, pending approvals. - Supply
renderLinkso navigation stays client-side. - Use the
footerslot for quiet metadata — a version string, an environment label.
Don't
- Invent hierarchy — the model is sections of links, one level deep, and that is a feature.
- Use badges as adverts or "new" flags; a permanent badge stops meaning anything.
- Let labels wrap — if a label needs two lines, it needs a shorter name.
- Put actions (log out, theme) in the rail — those live in the Topbar.
Accessibility & keyboard
- Renders an
<aside>landmark containing a single<nav>; the links are real anchors in a list, so screen readers report "list, n items" per group. - The active item carries
aria-current="page"— conveyed in speech, not just by colour. - Every link is named by its visible text label; icons are decoration beside it, never the only content.
- Focus is a 2px
--sidebar-ringoutline, tuned for the dark surface; all text/surface pairings meet WCAG 2.2 AA along the whole gradient, in both themes. - Keyboard: Tab moves through the links in DOM order; Enter follows one. Sections are static groups, not disclosures — there is nothing to expand or collapse.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sectionsrequired | NavSection[] | — | Grouped navigation model rendered in order. |
footer | React.ReactNode | — | Optional content pinned to the bottom, e.g. a version string. |
renderLink | ((props: NavLinkProps) => React.ReactNode) | undefined | — | Renders each navigation link. Supply your router's link component so navigation stays client-side — e.g. in Next.js: `renderLink={(props) => <Link {...props} />}`. Defaults to a plain `<a>`, which triggers a full page load. |
NavSection
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | undefined | — | Optional uppercase section heading; omit for the top (unlabelled) group. |
itemsrequired | NavItem[] | — | Navigation links in this section. |
NavItem
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | Link text. |
iconrequired | "search" | "menu" | "email" | "ascending" | "descending" | "insurer" | "corporateOrganisation" | "partneredProviders" | "revenue" | "searchMembers" | "treatments" | "tickets" | "financeMenu" | "emailTemplates" | "masterFile" | "sms" | "claims" | "guaranteeLetters" | "financeTransactions" | "payments" | "signatures" | "reports" | "administration" | "action" | "debugTools" | "exportToExcel" | "download" | "import" | "upload" | "upgrade" | "nextPage" | "previousPage" | "lastOfThePages" | "firstOfThePages" | "refresh" | "expandDown" | "expandRight" | "collapseUp" | "createNew" | "addNew" | "addNewProfile" | "information" | "folderClose" | "folderOpen" | "print" | "generateReport" | "share" | "bank" | "messageReceivedOnly" | "messageCanReply" | "pdpa" | "security" | "healthRelatedInsurance" | "tutorial" | "referralLetter" | "fieldDropDown" | "navigationDown" | "navigationUp" | "filterExpand" | "filterCollapse" | "externalLink" | "receipt" | "covid19Screening" | "collateral" | "creditLimitAndBalance" | "billingOverview" | "memberInformation" | "employees" | "medicalLeaves" | "analysis" | "comparison" | "homepage" | "dashboard" | "benefitGroups" | "makePayments" | "principal" | "dependants" | "remove" | "delete" | "approve" | "reject" | "cancel" | "delegate" | "batchAction" | "switchAccount" | "calendar" | "insurance" | "department" | "subsidiary" | "billingAccount" | "claimPolicies" | "default" | "globalUniversal" | "edit" | "allow" | "deny" | "addOn" | "revenueSubscription" | "help" | "contact" | "changePassword" | "manageAccount" | "login" | "loginActivities" | "logout" | "hospital" | "pharmacy" | "prescription" | "ultrasound" | "languages" | "map" | "details" | "properties" | "confirmation" | "newCheckIn" | "patientCheckIns" | "allGood" | "transactions" | "patient" | "lateClaims" | "doctors" | "outpatientSpecialist" | "inpatientHospitalisation" | "roles" | "users" | "auditLogs" | "chart" | "mobileAppEnabled" | "reimbursementClaims" | "preEmployment" | "gp" | "dental" | "optical" | "specialist" | "hospitalisation" | "maternity" | "healthScreening" | "pharmacy2" | "customTreatments" | "allergyAndImmunology" | "anaesthesiology" | "cardiologyAndAngiology" | "dentistry" | "dermatology" | "emergencyDepartment" | "endocrinology" | "gastroenterologyAndHepatology" | "generalSurgery" | "geriatricMedicine" | "haematology" | "infectiousDisease" | "internalMedicine" | "nephrology" | "neurology" | "obstetricsAndGynaecology" | "occupationalHealthAndVaccine" | "oncology" | "ophthalmology" | "oralAndMaxillofacial" | "orthopaedic" | "ent" | "paediatricDentistry" | "paediatrics" | "podiatry" | "psychiatry" | "pulmonologyAndRespiratory" | "radiologyAndImaging" | "reconstructivePlastic" | "rehabilitationMedicine" | "rheumatology" | "urology" | "vascularSurgery" | "xRay" | "femaleDoctorAvailable" | "open24Hours" | "covidTestRtk" | "covidTestPcr" | — | Leading icon, keyed by typed HealthMetrics icon name. |
hrefrequired | string | — | Destination for the link. |
active | boolean | undefined | false | Marks the current page; applies the active style and `aria-current="page"`. |
badge | string | number | undefined | — | Optional trailing count badge, e.g. unread items. |
renderLink receives a NavLinkProps object — href, className, children and an optional
aria-current — spread it onto your link component unchanged.
The sidebar with live controls in Storybook