TopBar
ComplexNavigation
<co-top-bar>TopBar is the 52px app header in all four styles: Classic navy bar with module links, patient search (Sidebar), patient tabs (Rail) or the Jump to anything bar (Command), then Viewing as, notifications and the account.
import { TopBar } from 'health-components';
Examples
Styles
Sidebar
Command
Usage
<TopBar variant={uiStyle} role={previewRole} roles={ROLES} notifications={unread} /> // uiStyle: classic | sidebar | rail | command
When to use
- Top of every desktop staff screen.
When not to use
- Phone, portal and kiosk screens: MobileHeader.
Variants and states
| Variant | What it is |
|---|---|
| classic | Default style. Navy nav-bg bar (#285278) with white logo and module links, white Viewing as pill. |
| sidebar | Search box left. |
| rail | PatientTabs left. |
| command | Logo, module switcher and the command bar. |
Accessibility
- header landmark; search input labelled "Search patients by name, MRN or DOB"; account button "Account menu".
Do and don't
- Do: Keep the right cluster in the same order in all three styles.
- Don't: Put page actions in the top bar.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | TopBarVariant | 'classic' | 'classic' navy bar with module links | 'sidebar' patient search | 'rail' patient tabs | 'command' Jump to anything bar |
role | string | none | Previewed role; shows RolePill when set |
roles | RoleOption[] | none (the current role only) | RolePill roles |
onRoleChange | (role: string) => void | none | Called with the role chosen in RolePill |
notifications | number | none | Unread notification count |
quickAdd | string | "New" | Quick add button label (not in classic) |
product | string | "CareOS" | Product name |
user | string | "Jordan Lee" | Signed-in user, shown as initials |
tabs | ReactNode | none | Rail only: the PatientTabs |
module | string | "Modules" | Command only: current module |
onOpenPalette | () => void | none | Command only: opens the CommandPalette |
onOpenModules | () => void | none | Command only: opens the module switcher |
links | string[] | Home, Schedule, Patients, Billing, Reports, Settings | Classic only: module links |
active | string | none | Classic only: current module link |
onNavigate | (link: string, event: MouseEvent<HTMLAnchorElement>) => void | none | Classic only: called when a module link is clicked |
linkHref | (link: string) => string | none (links call onNavigate) | Classic only: URL of each module link, for real navigation |
onSearchChange | (query: string) => void | none | Sidebar only: called as the patient search text changes |
onQuickAdd | () => void | none | Quick add handler |
onNotifications | () => void | none | Notifications button handler |
onAccount | () => void | none | Account button handler |
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-top-bar>. 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-top-bar variant="…" role="…" [roles]="roles" (co-role-change)="onRoleChange($event.detail)"></co-top-bar>
| Kind | Name | Description |
|---|---|---|
| attribute | variant | 'classic' navy bar with module links | 'sidebar' patient search | 'rail' patient tabs | 'command' Jump to anything bar; default 'classic' |
| attribute | role | Previewed role; shows RolePill when set; default none |
| property / JSON attribute | roles | RolePill roles; default none (the current role only) |
| attribute | notifications | Unread notification count; default none |
| attribute | quick-add / quickAdd | Quick add button label (not in classic); default "New" |
| attribute | product | Product name; default "CareOS" |
| attribute | user | Signed-in user, shown as initials; default "Jordan Lee" |
| attribute | module | Command only: current module; default "Modules" |
| property / JSON attribute | links | Classic only: module links; default Home, Schedule, Patients, Billing, Reports, Settings |
| attribute | active | Classic only: current module link; default none |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| property (function) | linkHref | Classic only: URL of each module link, for real navigation; default none (links call onNavigate) |
| event | co-role-change | Called with the role chosen in RolePill; default none (React: onRoleChange) |
| event | co-open-palette | Command only: opens the CommandPalette; default none (React: onOpenPalette) |
| event | co-open-modules | Command only: opens the module switcher; default none (React: onOpenModules) |
| event | co-navigate | Classic only: called when a module link is clicked; default none (React: onNavigate) |
| event | co-search-change | Sidebar only: called as the patient search text changes; default none (React: onSearchChange) |
| event | co-quick-add | Quick add handler; default none (React: onQuickAdd) |
| event | co-notifications | Notifications button handler; default none (React: onNotifications) |
| event | co-account | Account button handler; default none (React: onAccount) |
| slot | tabs | Rail only: the PatientTabs; default none Plain text also works as the `tabs` attribute. |