Drawer

A panel from the edge of the screen for editing one item while the page stays in view.

Live React portVue source: WildDrawer.vueStorybook story: Feedback/DrawerReact component: WildDrawer

Try it

Open the drawer, change a setting, then close it with Escape, the scrim or a button.

Sites
Bore 12North paddock
Bore 14North paddock
Tank 3Home block
Pump stationRiver flats
Tank 7River flats
Position
Size
Close button
Close on scrim
<WildDrawer
  :open="open"
  title="Bore 12"
  position="right"
  size="md"
  @close="open = false"
>
  …
  <template #footer>…</template>
</WildDrawer>

When to use

  • Use a drawer to edit or inspect one item while the list behind it stays in view.
  • Use it for settings and short forms that belong to the current page.
Don’t use it
  • To confirm a deletion or other decision that should stop the work. Use a confirm dialog.
  • For a short task that doesn’t need the page behind it. Use a dialog.
  • For the app’s main navigation. Use Sidebar nav.
  • Inside another drawer. Replace the drawer’s content, or move the task to its own page.

Anatomy

A header with the title and close button, a body that scrolls, and a footer for actions. The panel fills the height of the screen.

Sites
Bore 12North paddock
Bore 14North paddock
Tank 3Home block
Pump stationRiver flats
Tank 7River flats
Bore 12
Site name
Bore 12
Group
North paddock
SMS alertsImmediate
<WildDrawer :open="open" title="Bore 12" @close="open = false">
  …
  <template #footer>
    <WildButton variant="secondary" size="sm">Cancel</WildButton>
    <WildButton size="sm">Save changes</WildButton>
  </template>
</WildDrawer>

Position

Right is the default, for detail views and forms. Use left for secondary content.

Sites
Bore 12North paddock
Bore 14North paddock
Tank 3Home block
Pump stationRiver flats
Tank 7River flats
Bore 12
Site name
Bore 12
Group
North paddock
SMS alertsImmediate
<WildDrawer :open="open" position="left" title="Bore 12" />

Content

  • Title the drawer with the name of the thing it shows: the site, logger or alarm.
  • Put the primary action last in the footer, and start it with a verb.
  • Keep the body to one task. A second task needs its own drawer or page.

Accessibility

The drawer is announced as a dialog named by its title. Focus moves into it on open, stays inside it, and returns to the control that opened it.

KeyWhat it does
Tab / Shift+TabMoves through the drawer’s controls, wrapping at either end.
EscapeCloses the drawer. An open list inside it closes first.
Enter / SpaceOn the close button, closes the drawer.

Props

PropTypeDefaultDescription
openboolean—Shows the drawer. Required.
titlestring—Heading in the header, and the accessible name.
size'sm' | 'md' | 'lg' | 'xl' | 'full''md'320, 400, 560, 720px or full; full at 640px and under.
position'left' | 'right''right'The edge it slides in from.
showClosebooleantrueShows the close button in the header.
closeOnOverlaybooleantrueCloses when the scrim is clicked.
closeOnEscbooleantrueCloses when Escape is pressed.
ariaLabelstring—Accessible name when there is no title.
@closeevent—Fired when the drawer asks to close.
#headerslot—Replaces the title. The close button stays.
#footerslot—Actions, aligned right.

Tokens

TokenValueWhere it lands
--dialog-overlayrgba(10, 9, 11, 0.5)Scrim, shared with the dialog, 2px blur.
(no token)0 20px 25px -5px …The dialog’s panel shadow.
--global-neutral-grey-500#E6E6E6Leading edge, header and footer rules.
--global-neutral-grey-1200#1D1C20Title, 18px at 600.
--duration-slow300msSlide in, with --ease-out.
--duration-moderate200msSlide out, with --ease-in.
(no token)1000Z-index, above toolbars.