Components
Drawer
Full-height modal panel that slides in from the right edge, with swipe to dismiss and two widths.
import { Button, Drawer } from "@openperf/deft";
<Drawer.Root swipeDirection="right">
<Drawer.Trigger render={<Button.Root />}>Details</Drawer.Trigger>
<Drawer.Content>
<Drawer.Header>
<Drawer.Title>Release 2.4.0</Drawer.Title>
</Drawer.Header>
<Drawer.Body>12 commits from 3 authors.</Drawer.Body>
</Drawer.Content>
</Drawer.Root>;When to use
| Need | Component |
|---|---|
| Supporting content too long for a dialog | Drawer |
| Short task or form in a centered window | Dialog |
| Confirm an action before it runs | Confirm dialog |
| Small panel next to its trigger, page stays usable | Popover |
| Navigation that is part of the app layout | Sidebar |
Anatomy
<Drawer.Root>
<Drawer.Trigger />
{/* portal, backdrop, viewport, popup and close button */}
<Drawer.Content>
<Drawer.Header>
<Drawer.Title />
<Drawer.Description />
</Drawer.Header>
<Drawer.Body /> {/* scrolls; header and footer stay in place */}
<Drawer.Footer>
<Drawer.Close />
</Drawer.Footer>
</Drawer.Content>
</Drawer.Root>Drawer.Header, Drawer.Body and Drawer.Footer are the Dialog parts and all three are optional. Render Drawer.Title, or pass aria-label to Drawer.Content when there is no visible heading.
Sizes
| Size | Max width |
|---|---|
md | 360px |
lg | 480px |
The panel takes the full height of the screen and the full width up to its maximum.
Swipe to dismiss
Set swipeDirection="right" on Drawer.Root. The panel follows a horizontal swipe, but Base UI swipes down by default.
Detached triggers
Create a handle with Drawer.createHandle() and pass it to Drawer.Root and to each Drawer.Trigger, as for a Dialog. Deft exports no handle type for Drawer: type one in props with ReturnType<typeof Drawer.createHandle>.
API
Drawer.Root, Drawer.Trigger, Drawer.Close and Drawer.createHandle are Base UI exports, unchanged. Drawer.Content replaces the Base UI part of the same name.
Drawer.Content
The close button label is a Lingui message, so render the drawer under the root providers.
Prop
Type