Skip to main content

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​

Storybook
Storybook

Command​

Storybook

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​

VariantWhat it is
classicDefault style. Navy nav-bg bar (#285278) with white logo and module links, white Viewing as pill.
sidebarSearch box left.
railPatientTabs left.
commandLogo, 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​

PropTypeDefaultDescription
variantTopBarVariant'classic''classic' navy bar with module links | 'sidebar' patient search | 'rail' patient tabs | 'command' Jump to anything bar
rolestringnonePreviewed role; shows RolePill when set
rolesRoleOption[]none (the current role only)RolePill roles
onRoleChange(role: string) => voidnoneCalled with the role chosen in RolePill
notificationsnumbernoneUnread notification count
quickAddstring"New"Quick add button label (not in classic)
productstring"CareOS"Product name
userstring"Jordan Lee"Signed-in user, shown as initials
tabsReactNodenoneRail only: the PatientTabs
modulestring"Modules"Command only: current module
onOpenPalette() => voidnoneCommand only: opens the CommandPalette
onOpenModules() => voidnoneCommand only: opens the module switcher
linksstring[]Home, Schedule, Patients, Billing, Reports, SettingsClassic only: module links
activestringnoneClassic only: current module link
onNavigate(link: string, event: MouseEvent<HTMLAnchorElement>) => voidnoneClassic only: called when a module link is clicked
linkHref(link: string) => stringnone (links call onNavigate)Classic only: URL of each module link, for real navigation
onSearchChange(query: string) => voidnoneSidebar only: called as the patient search text changes
onQuickAdd() => voidnoneQuick add handler
onNotifications() => voidnoneNotifications button handler
onAccount() => voidnoneAccount 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>
KindNameDescription
attributevariant'classic' navy bar with module links | 'sidebar' patient search | 'rail' patient tabs | 'command' Jump to anything bar; default 'classic'
attributerolePreviewed role; shows RolePill when set; default none
property / JSON attributerolesRolePill roles; default none (the current role only)
attributenotificationsUnread notification count; default none
attributequick-add / quickAddQuick add button label (not in classic); default "New"
attributeproductProduct name; default "CareOS"
attributeuserSigned-in user, shown as initials; default "Jordan Lee"
attributemoduleCommand only: current module; default "Modules"
property / JSON attributelinksClassic only: module links; default Home, Schedule, Patients, Billing, Reports, Settings
attributeactiveClassic only: current module link; default none
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
property (function)linkHrefClassic only: URL of each module link, for real navigation; default none (links call onNavigate)
eventco-role-changeCalled with the role chosen in RolePill; default none (React: onRoleChange)
eventco-open-paletteCommand only: opens the CommandPalette; default none (React: onOpenPalette)
eventco-open-modulesCommand only: opens the module switcher; default none (React: onOpenModules)
eventco-navigateClassic only: called when a module link is clicked; default none (React: onNavigate)
eventco-search-changeSidebar only: called as the patient search text changes; default none (React: onSearchChange)
eventco-quick-addQuick add handler; default none (React: onQuickAdd)
eventco-notificationsNotifications button handler; default none (React: onNotifications)
eventco-accountAccount button handler; default none (React: onAccount)
slottabsRail only: the PatientTabs; default none Plain text also works as the `tabs` attribute.