Drawer
BasicOverlays
<co-drawer>Drawer slides a panel in from the right for detail and secondary forms, including the "For developers" panel, or up from the bottom on phones.
import { Drawer } from 'health-components';
Examples
Showcase
Bottom Sheet
Open From Button
Usage
<Drawer title="Claim CLM-20871" onClose={close} footer={<Button variant="primary">Resubmit</Button>}>...</Drawer>
<Drawer side="bottom" title="Visit options">...</Drawer>
When to use
- Record detail while keeping the list visible (claim detail from the queue), filters, the developer panel, phone action sheets.
When not to use
- A yes or no decision: Modal.
Variants and states
| Variant | What it is |
|---|---|
| right | 560px, full height. |
| developer | Code icon, "For developers: <screen>", sections of purpose, data, API and states in mono. |
| bottom | Sheet with grab handle, radius 16 top corners, 430px max. |
| width | Custom px. |
Accessibility
- dialog with aria-modal, labelled by the title; Escape closes.
- The developer close button is named "Close developer panel", as in the screens.
Do and don't
- Do: Developer drawer: purpose and roles, data fields, API calls, states, in that order.
- Don't: A drawer that opens another drawer.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | true | Whether the drawer is shown |
title * | string | — | Drawer title; names the dialog. Required. |
side | DrawerSide | 'right' | 'right' panel or 'bottom' sheet (phones) |
developer | boolean | false | The "For developers" panel: code icon, "For developers: <title>" |
sections | DrawerSection[] | none | Developer drawer sections; replace `children` when `developer` is set |
children | ReactNode | none | Body |
footer | ReactNode | none | Footer actions |
width | number | 560 (from CSS) | Panel width in px |
onClose | () => void | none | Called by the x button, Escape and a scrim press |
inline | boolean | false | Render in place for docs: no portal, focus trap, scroll lock or Escape |
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-drawer>. 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-drawer open title="…" [sections]="sections" (co-close)="onClose($event.detail)">…</co-drawer>
| Kind | Name | Description |
|---|---|---|
| attribute | open | Whether the drawer is shown; default true |
| attribute | title | Drawer title; names the dialog. Required. |
| attribute | side | 'right' panel or 'bottom' sheet (phones); default 'right' |
| attribute | developer | The "For developers" panel: code icon, "For developers: <title>"; default false |
| property / JSON attribute | sections | Developer drawer sections; replace `children` when `developer` is set; default none |
| attribute | width | Panel width in px; default 560 (from CSS) |
| attribute | inline | Render in place for docs: no portal, focus trap, scroll lock or Escape; default false |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-close | Called by the x button, Escape and a scrim press; default none (React: onClose) |
| slot | (default) | Body; default none |
| slot | footer | Footer actions; default none Plain text also works as the `footer` attribute. |