Drawer
A side panel over a scrim for secondary work — filters, drilldowns, stepping through records.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
A side panel over a scrim for secondary work — filters, drilldowns, stepping through records.
Import
import { Drawer, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerNav, DrawerActions, DrawerBack, DrawerPrevious, DrawerNext, DrawerCounter, DrawerExpand, DrawerCloseButton, DrawerHeading, DrawerIcon, DrawerTitleGroup, DrawerTitle, DrawerDescription, DrawerTabs, DrawerBody, DrawerFooter } from "@ir/ui";Watch out
- The two rules are different tokens, as drawn. The header's bottom rule is border/neutral/subtle; the footer's top rule is border/neutral/muted. Followed rather than evened out, and raised — if the two rules are meant to match, the file is the place to settle it.
- Heights run 4px taller than the Figma frames, and this is the Button offset, not a new departure. Figma draws the header's icon buttons at Ghost/icon-sm = 28 and the footer's at md = 32; code's Button is deliberately one step taller at every size (see button.tsx), so icon-sm is 32 and md is 36. Mapping by NAME rather than by pixel keeps a design reading straight into props, so the record header measures 49 rather than 45 and the footer 69 rather than 64. Both are padding-driven here — no fixed height to fight the button.
Variants
| Axis | Options | Default |
|---|---|---|
side | end · start · expanded | end |
type | record · title | record |
Props
| Prop | Type | Required | What it does |
|---|---|---|---|
label | string | The drawer's accessible name, for a drawer with no visible DrawerTitle — a record header carries a counter, not a title, so it needs one here. Rendered as a screen-reader-only title. ⚠️ Mutually exclusive with DrawerTitle. Both render a Radix Title, both Titles get the same id, and the hidden one wins the accessible name — so a drawer with a perfectly good visible title would announce itself as something else entirely. Warns in development. |
Do and don't
Use a Dialog for a focused interruption; a Drawer for work the page's context still matters to.
Don't — Reach for a Drawer because the Dialog felt cramped.
A drawer leaves the page visible on purpose. If the page behind is irrelevant, the modal was the right shape.
Pick Default 480 or Wide 640 for a side panel; Expanded ignores size.
Don't — Set size="wide" on an expanded drawer.
The file draws five variants, not six — Expanded is already the wide one, inset 80 by 40.
Pass label — "Endpoint 3 of 227: probe-04".
Don't — Ship a record header with no accessible name because it shows a counter instead of a title.
"3 of 227" is not a name. Someone arriving by screen reader gets a dialog that will not say what it is.
One or the other — label for record headers, DrawerTitle everywhere else.
Don't — Set label and render a DrawerTitle.
Both render a title with the same id and the hidden one wins, so the visible title is silently ignored.
Keep up and down — they move through the list behind the drawer.
Don't — Swap the chevrons to left and right because the drawer came in from the right.
The arrows describe what moves, and what moves is the selection in a vertical list, not the panel.
Keep the commitment in the footer, where it stays put while the body scrolls.
Don't — Scatter Apply and Reset through the body next to the fields they affect.
The body scrolls and the footer does not. An action that scrolls out of reach is one people stop finding.
Primary last, on the right, paired with a secondary or an outline.
Don't — Lead with the primary action, or pair it with a ghost button.
The eye finishes at the right-hand edge, so that is where the commitment belongs — and a ghost beside it reads as a third-tier action rather than the way out.
Replace the content in place, or step with previous and next.
Don't — Open a drawer from inside a drawer.
Two focus traps and two Escape handlers, and nobody can tell which layer they are answering.
Accessibility
- Built on Radix Dialog, so it is a modal: focus is trapped, Escape closes, and the page behind is inert.
- label renders an sr-only DialogTitle. Without it Radix has no accessible name for the drawer and warns in development, so pass it even when the header already shows the name visually.
- Every header control — previous, next, expand, close — is an icon-only button taking its own label. The glyphs are all aria-hidden.
- The divider between header controls is aria-hidden; it is a drawn line, not a separator anyone needs announced.
Where it is drawn
Figma — structure from figma, measurements from figma.