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
Collapsed
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
| Variant | What it is |
|---|---|
| expanded | 240px with group labels. |
| collapsed | 64px icons; labels move to title and screen-reader text. |
| active | primary-soft with a 3px primary inset bar. |
| badge | Count on Inbox. |
| locked | Lock 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
| Prop | Type | Default | Description |
|---|---|---|---|
groups * | SidebarNavGroup[] | — | Groups in a fixed order; only the items change per role. Required. |
active | string | none | Label of the current item |
collapsed | boolean | uncontrolled | Collapsed to the 64px icon strip (controlled) |
defaultCollapsed | boolean | false | Initially collapsed when uncontrolled |
product | string | "CareOS" | Product name next to the logo mark |
onCollapse | (collapsed: boolean) => void | none | Called with the new collapsed state |
onNavigate | (item: SidebarNavItem, event: MouseEvent<HTMLAnchorElement>) => void | none | Called when an item is clicked |
inline | boolean | false | Bordered, 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>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | groups | Groups in a fixed order; only the items change per role. Required. |
| attribute | active | Label of the current item; default none |
| attribute | collapsed | Collapsed to the 64px icon strip (controlled); default uncontrolled |
| attribute | default-collapsed / defaultCollapsed | Initially collapsed when uncontrolled; default false |
| attribute | product | Product name next to the logo mark; default "CareOS" |
| attribute | inline | Bordered, for docs; default false |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-collapse | Called with the new collapsed state; default none (React: onCollapse) |
| event | co-navigate | Called when an item is clicked; default none (React: onNavigate) |