Overlays
Drawer
A modal panel that slides in from an edge — the Dialog in another shape, with the same focus management, Escape, backdrop and scroll lock.
import { Drawer } from '@reactloom/ui';Examples
Detail panel
import { Badge, Button, DescriptionList, Drawer } from '@reactloom/ui';
export default function Example() {
return (
<Drawer.Root>
<Drawer.Trigger variant="secondary">View invoice</Drawer.Trigger>
<Drawer.Content>
<Drawer.Header>
<Drawer.Title>Invoice INV-2041</Drawer.Title>
<Drawer.Description>Acme Corporation</Drawer.Description>
</Drawer.Header>
<Drawer.Body>
<DescriptionList>
<DescriptionList.Item term="Status"><Badge tone="warning" dot>Overdue</Badge></DescriptionList.Item>
<DescriptionList.Item term="Amount">$12,400.00</DescriptionList.Item>
<DescriptionList.Item term="Due">12 November 2026</DescriptionList.Item>
</DescriptionList>
</Drawer.Body>
<Drawer.Footer>
<Drawer.Close>Close</Drawer.Close>
<Button>Send reminder</Button>
</Drawer.Footer>
</Drawer.Content>
</Drawer.Root>
);
}Sides
start and end follow the text direction.
import { Drawer, HStack } from '@reactloom/ui';
export default function Example() {
return (
<HStack gap="2">
{(['start', 'end', 'bottom'] as const).map((side) => (
<Drawer.Root key={side}>
<Drawer.Trigger variant="secondary">{side}</Drawer.Trigger>
<Drawer.Content side={side} size="sm">
<Drawer.Header>
<Drawer.Title>Drawer from {side}</Drawer.Title>
</Drawer.Header>
<Drawer.Body>start and end follow the text direction.</Drawer.Body>
</Drawer.Content>
</Drawer.Root>
))}
</HStack>
);
}API reference
Drawer.Content
| Prop | Type | Default |
|---|---|---|
side | 'start' | 'end' | 'bottom' | 'end' |
sizeWidth (or height for bottom); token --pl-drawer-size. | 'sm' | 'md' | 'lg' | 'md' |
…Everything Dialog.Content accepts. | DialogContentProps | — |
Other parts
| Prop | Type | Default |
|---|---|---|
Root · Trigger · Header · Title · Description · Body · Footer · CloseSame as Dialog. | | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
Renders DialogContent, so its hooks apply too.
Slot class names
Add classes to inner parts with classNames (className is shorthand for root): root, panel, closeButton.
CSS variables
| Variable | Default |
|---|---|
--pl-drawer-size | var(--_size |
--pl-dialog-radius | var(--pl-radius-xl |
--pl-dialog-width | 25rem |
--pl-dialog-width | 35rem |
--pl-dialog-width | 45rem |
--pl-dialog-width | 60rem |
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-drawer-size] | present when on |
[data-side] | start · end · bottom |
[data-size] | sm · md · lg · xl · full |
Theme tokens it reads
--pl-color-bg-overlay --pl-color-bg-surface-raised --pl-color-border-default --pl-color-fg-default --pl-color-fg-muted --pl-radius-xl --pl-shadow-lg
Accessibility
- Identical to Dialog: inert background, focus return, Escape, labelled by Drawer.Title.
| Key | Action |
|---|---|
| Escape | Close |
| Tab | Cycle inside the drawer |
Usage guidelines
Do
- Use for details and secondary tasks without leaving the page.
Don’t
- Don’t stack drawers.