Skip to content
Browse docs and components

Drawer

drawer

A bottom sheet on the Base UI dialog, so it keeps the focus trap, Esc and focus return. Drag it down by the handle or header and it follows your finger, then springs back or closes when pulled past a third of its height or flicked.

Responsive

Install

$npxshadcnadd@forme/drawer

Adds the component, its registry dependencies, and the token stylesheet you import once.

Usage

import {
  Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger,
} from "@/components/forme/drawer/drawer";

<Drawer>
  <DrawerTrigger asChild>
    <Button variant="secondary">Filters</Button>
  </DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Filter listings</DrawerTitle>
    </DrawerHeader>
    <DrawerBody>…</DrawerBody>
  </DrawerContent>
</Drawer>

When to use

Reach for it

  • Panels on a phone: filters, a share sheet, the details of a row.

Use something else

  • Desktop layouts where a side panel or a Dialog reads better than a sheet from the bottom.

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

DrawerTrigger

PropTypeDefaultDescription
asChildboolean—

Also takes every prop of Base UI Dialog.Trigger.

DrawerClose

PropTypeDefaultDescription
asChildboolean—

Also takes every prop of Base UI Dialog.Close.

The other parts

  • DrawerTakes Base UI Dialog.Root
  • DrawerContentTakes Base UI Dialog.Popup
  • DrawerHeaderTakes <div> attributes
  • DrawerBodyTakes <div> attributes
  • DrawerFooterTakes <div> attributes
  • DrawerTitleTakes Base UI Dialog.Title
  • DrawerDescriptionTakes Base UI Dialog.Description

Accessibility

  • It is a Base UI dialog underneath: focus is trapped, the page is inert, Esc closes it and focus returns to the trigger.

Motion

  • Drag the handle or header and the sheet follows the finger; past a third of its height, or on a quick flick, it closes.
  • The drag writes a transform straight to the element, so it keeps up with the pointer without re-rendering.

Responsive behaviour

  • The footer's buttons stack on a phone and sit in a row from sm.