Skip to main content

PatientTabs

ComplexNavigation<co-patient-tabs>

PatientTabs keep several open patients as closable tabs across the top, like a browser, in the Focus Rail style.

import { PatientTabs } from 'health-components';

Examples​

Two Charts​

Storybook

Usage​

<PatientTabs tabs={openCharts} active={currentId} onChange={setCurrentId} onClose={closeChart} onAdd={openSearch} />

When to use​

  • Providers switching between charts during a session.

When not to use​

  • Phones.
  • More than about 8 open charts: suggest closing some.

Variants and states​

VariantWhat it is
activeWhite tab with accent line.
inactivecanvas tab.
pinnedA screen tab such as Schedule that cannot close.
metaAge and sex after the name.

Accessibility​

  • tablist; each close button names the patient ("Close Henna West").
  • Arrow keys, Home and End move between tabs; Delete closes the focused tab. The close buttons are pointer shortcuts outside the tab order, so the tablist holds only tabs; the add button sits after the tablist.

Do and don't​

  • Do: Show sex and age so two patients with similar names are told apart.
  • Don't: Close tabs on sign-out without saving drafts.

Props​

PropTypeDefaultDescription
tabs *PatientTab[]—Open tabs. Required.
activestringuncontrolledActive tab id (controlled)
defaultActivestringthe first tabInitially active tab id when uncontrolled
onChange(id: string) => voidnoneCalled with the newly active tab id
onClose(tab: PatientTab) => voidnoneCalled when a tab is closed (x button or Delete key). The tab is also hidden internally
onAdd() => voidnoneAdd (+) button handler
addLabelstring"Open another patient"Accessible name of the add button

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-patient-tabs>. 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-patient-tabs active="…" default-active="…" [tabs]="tabs" (co-change)="onChange($event.detail)"></co-patient-tabs>
KindNameDescription
property / JSON attributetabsOpen tabs. Required.
attributeactiveActive tab id (controlled); default uncontrolled
attributedefault-active / defaultActiveInitially active tab id when uncontrolled; default the first tab
attributeadd-label / addLabelAccessible name of the add button; default "Open another patient"
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-changeCalled with the newly active tab id; default none (React: onChange)
eventco-closeCalled when a tab is closed (x button or Delete key). The tab is also hidden internally; default none (React: onClose)
eventco-addAdd (+) button handler; default none (React: onAdd)