Skip to content

Overlay

Drawer

Slide-over panel for secondary flows.

import { Drawer } from '@var-ui/react';

Drawer

Slide-over panel for secondary flows (settings, details, filters). Built on the native <dialog>: showModal() provides the focus trap, the inert page, Escape and the top layer. Drawer is the compound Root (Drawer.Trigger, Drawer.Popup, Drawer.Header, Drawer.Title, Drawer.Close, Drawer.Body) with open / defaultOpen / onOpenChange(open, details); dismissable is a Root prop. Drawer.Popup is the <dialog> itself: it renders in place (no portal, no portalContainer) and its backdrop is ::backdrop (there is no Backdrop part). A Drawer.Trigger must be a button (a Button or a host <button>); a Drawer.Close child receives onClick — there is no render prop.

There is no assembled preset: the recipe below (trigger, popup with a header, title, close and body) is the usual arrangement, so copy it and change what you need.

State attributes, exit animation, and onOpenChange details are documented in Overlay lifecycle.

Examples

Default

The recipe: a trigger, then a header with title and close above the body. placement defaults to end.

Demo.tsxTSX
import { Button, Drawer } from '@var-ui/react';

<Drawer>
  <Drawer.Trigger>
    <Button>Open drawer</Button>
  </Drawer.Trigger>
  <Drawer.Popup aria-label="Settings">
    <Drawer.Header>
      <Drawer.Title>Settings</Drawer.Title>
      <Drawer.Close />
    </Drawer.Header>
    <Drawer.Body>
      <p>Drawer body content.</p>
    </Drawer.Body>
  </Drawer.Popup>
</Drawer>

Placement

Set placement on Drawer.Popup (start, end, or bottom) to match the layout edge that owns the flow. start and end are logical: they follow the writing direction, so start docks on the right in RTL. The popup slides in with translate and @starting-style.

Demo.tsxTSX
import { Button, Drawer } from '@var-ui/react';

<Drawer>
  <Drawer.Trigger>
    <Button>Open from start</Button>
  </Drawer.Trigger>
  <Drawer.Popup placement="start" aria-label="Filters">
    <Drawer.Header>
      <Drawer.Title>Filters</Drawer.Title>
      <Drawer.Close />
    </Drawer.Header>
    <Drawer.Body>
      <p>Popup slides in from the start edge.</p>
    </Drawer.Body>
  </Drawer.Popup>
</Drawer>

Props

Accessibility

Focus moves into the popup when opened and returns to the trigger on close; the page behind it is inert and its scroll is locked. Escape always reports escape-key; a backdrop press reports outside-press only while dismissable is true. Name the dialog with aria-label / aria-labelledby on Drawer.Popup (or aria-label on the Root). The close control defaults to aria-label="Close". Prefer drawers for multi-step or longer secondary UI; use AlertDialog for short confirmations.