Skip to main content

SidebarNav

ComplexNavigation<co-sidebar-nav>

SidebarNav is the Clinical Sidebar style's grouped left navigation, 240px wide, collapsing to a 64px icon strip.

import { SidebarNav } from 'health-components';

Examples​

Expanded And Collapsed​

Storybook

Collapsed​

Storybook

Usage​

<SidebarNav groups={NAV_GROUPS_FOR_ROLE} active="Schedule" collapsed={prefs.collapsed} onCollapse={saveCollapsed} />

When to use​

  • Clinical Sidebar style on desktop.

When not to use​

  • Phones: BottomTabBar.
  • Focus Rail and Command Bar styles.

Variants and states​

VariantWhat it is
expanded240px with group labels.
collapsed64px icons; labels move to title and screen-reader text.
activeprimary-soft with a 3px primary inset bar.
badgeCount on Inbox.
lockedLock icon on items the role can only view.

Accessibility​

  • nav "Main"; aria-current="page".
  • Collapse button says "Collapse sidebar" or "Expand sidebar" and has aria-expanded.
  • Items the role cannot use at all are removed (none level), not shown disabled.

Do and don't​

  • Do: Same group order for every role; only the items change.
  • Don't: Reorder groups per user.

Props​

PropTypeDefaultDescription
groups *SidebarNavGroup[]—Groups in a fixed order; only the items change per role. Required.
activestringnoneLabel of the current item
collapsedbooleanuncontrolledCollapsed to the 64px icon strip (controlled)
defaultCollapsedbooleanfalseInitially collapsed when uncontrolled
productstring"CareOS"Product name next to the logo mark
onCollapse(collapsed: boolean) => voidnoneCalled with the new collapsed state
onNavigate(item: SidebarNavItem, event: MouseEvent<HTMLAnchorElement>) => voidnoneCalled when an item is clicked
inlinebooleanfalseBordered, for docs

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-sidebar-nav>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-sidebar-nav active="…" collapsed [groups]="groups" (co-collapse)="onCollapse($event.detail)"></co-sidebar-nav>
KindNameDescription
property / JSON attributegroupsGroups in a fixed order; only the items change per role. Required.
attributeactiveLabel of the current item; default none
attributecollapsedCollapsed to the 64px icon strip (controlled); default uncontrolled
attributedefault-collapsed / defaultCollapsedInitially collapsed when uncontrolled; default false
attributeproductProduct name next to the logo mark; default "CareOS"
attributeinlineBordered, for docs; default false
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-collapseCalled with the new collapsed state; default none (React: onCollapse)
eventco-navigateCalled when an item is clicked; default none (React: onNavigate)