Skip to main content

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​

Storybook

Bottom Sheet​

Storybook

Open From Button​

Storybook

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​

VariantWhat it is
right560px, full height.
developerCode icon, "For developers: <screen>", sections of purpose, data, API and states in mono.
bottomSheet with grab handle, radius 16 top corners, 430px max.
widthCustom 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​

PropTypeDefaultDescription
openbooleantrueWhether the drawer is shown
title *string—Drawer title; names the dialog. Required.
sideDrawerSide'right''right' panel or 'bottom' sheet (phones)
developerbooleanfalseThe "For developers" panel: code icon, "For developers: <title>"
sectionsDrawerSection[]noneDeveloper drawer sections; replace `children` when `developer` is set
childrenReactNodenoneBody
footerReactNodenoneFooter actions
widthnumber560 (from CSS)Panel width in px
onClose() => voidnoneCalled by the x button, Escape and a scrim press
inlinebooleanfalseRender 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>
KindNameDescription
attributeopenWhether the drawer is shown; default true
attributetitleDrawer title; names the dialog. Required.
attributeside'right' panel or 'bottom' sheet (phones); default 'right'
attributedeveloperThe "For developers" panel: code icon, "For developers: <title>"; default false
property / JSON attributesectionsDeveloper drawer sections; replace `children` when `developer` is set; default none
attributewidthPanel width in px; default 560 (from CSS)
attributeinlineRender in place for docs: no portal, focus trap, scroll lock or Escape; default false
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-closeCalled by the x button, Escape and a scrim press; default none (React: onClose)
slot(default)Body; default none
slotfooterFooter actions; default none Plain text also works as the `footer` attribute.