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
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
| Variant | What it is |
|---|---|
| active | White tab with accent line. |
| inactive | canvas tab. |
| pinned | A screen tab such as Schedule that cannot close. |
| meta | Age 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
| Prop | Type | Default | Description |
|---|---|---|---|
tabs * | PatientTab[] | — | Open tabs. Required. |
active | string | uncontrolled | Active tab id (controlled) |
defaultActive | string | the first tab | Initially active tab id when uncontrolled |
onChange | (id: string) => void | none | Called with the newly active tab id |
onClose | (tab: PatientTab) => void | none | Called when a tab is closed (x button or Delete key). The tab is also hidden internally |
onAdd | () => void | none | Add (+) button handler |
addLabel | string | "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>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | tabs | Open tabs. Required. |
| attribute | active | Active tab id (controlled); default uncontrolled |
| attribute | default-active / defaultActive | Initially active tab id when uncontrolled; default the first tab |
| attribute | add-label / addLabel | Accessible name of the add button; default "Open another patient" |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-change | Called with the newly active tab id; default none (React: onChange) |
| event | co-close | Called when a tab is closed (x button or Delete key). The tab is also hidden internally; default none (React: onClose) |
| event | co-add | Add (+) button handler; default none (React: onAdd) |