Drawer
Edge-anchored panel on Ark UI's Drawer machine — swipe-to-dismiss, snap points and a drag grabber, with an RTL-aware placement prop.
The Drawer is an edge-anchored panel built on Ark UI's Drawer state machine — so it ships swipe-to-dismiss, snap points and a drag grabber out of the box. The kit layers on an RTL-aware placement prop (Ark has none): docking, sizing and the slide animation are pure CSS keyed on data-placement, so start/end flip automatically under dir="rtl".
import { Drawer } from '@42-central/ui-react/drawer';
<Drawer open={open} onOpenChange={setOpen} placement="end" title="Filters">
<Text>Slides in from the inline-end edge.</Text>
</Drawer>Placement
placement accepts the logical edges start / end / top / bottom. start and end resolve against text direction.
Code
<Drawer placement="start" … />
<Drawer placement="end" … /> // default
<Drawer placement="top" … />
<Drawer placement="bottom" … />Sizes
Inline placements (start / end) size on width; block placements (top / bottom) size on height. Both read the size token (xs–xl).
Code
<Drawer placement="end" size="sm" … />
<Drawer placement="end" size="lg" … />Radius
radius rounds the two corners away from the docked edge, so the panel stays flush with the edge it slides out of. The corners are logical: a start or end drawer's rounded side mirrors with it under dir="rtl". It takes the same scale as Modal and defaults to none.
Code
<Drawer placement="end" radius="lg" … />
<Drawer placement="bottom" radius="lg" … />Grabber
Set withGrabber to show a draggable handle — useful for bottom sheets on touch devices, where the whole panel is swipe-dismissable.
Code
<Drawer placement="bottom" withGrabber title="Quick actions" … />Icons
icons replaces the kit's icons. Drawer has one, close, for the header's close button. It sits on the ready-made Drawer and on Drawer.Root, where Drawer.CloseTrigger reads it; a Drawer.CloseTrigger's own children win over it. A missing key keeps its default. To drop the button, set withCloseButton={false} rather than a null icon.
The icon you pass is drawn as given. An arrow that points at the drawer's edge should mirror on a right-to-left page, where end is on the left: add rtl:-scale-x-100. Add className={iconStroke} (from @42/ui-react) to draw it in the kit's 1.5px line.
Code
<Drawer
placement="end"
title="Filters"
icons={{ close: <PanelRightCloseIcon className={cn(iconStroke, "rtl:-scale-x-100")} /> }}
…
/>Composable parts
Like Modal, the high-level <Drawer> is backed by parts for full control, shaped the same way: the parts style themselves from props. They live on the Drawer namespace only (Drawer.Root, Drawer.Title, …); @42/ui-react/drawer exports no flat DrawerRoot-style names.
Set placement once, on Drawer.Root. The root derives Ark's swipe direction from it, and Drawer.Positioner and Drawer.Content read it to dock, size and animate themselves. Drawer.Content takes size and radius, as Modal.Content does.
<Drawer.Root placement="start">
<Drawer.Trigger asChild>
<Button>Filters</Button>
</Drawer.Trigger>
<Drawer.Backdrop />
<Drawer.Positioner>
<Drawer.Content size="sm" radius="md">
<Drawer.Header>
<Drawer.Title>Filters</Drawer.Title>
<Drawer.CloseTrigger />
</Drawer.Header>
<Drawer.Body>…</Drawer.Body>
<Drawer.Footer>
<Drawer.CloseTrigger asChild>
<Button variant="subtle">Done</Button>
</Drawer.CloseTrigger>
</Drawer.Footer>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>Drawer.Body is a vertical ScrollArea that takes the space between the header and the footer. Its className (and its other props) land on the scrolled content, where the padding and the children's layout live, so className="flex flex-col gap-4" or p-0 work as you'd expect. When the content owns its own scroller (a list with its own height, a header that must stay put), pass scrollable={false}, on Drawer.Body or on the ready-made Drawer: the body becomes a plain column that takes the space left and lets that scroller shrink (min-h-0), so a short screen shrinks your list instead of scrolling the whole body. Spotlight does this.
An explicit swipeDirection on Drawer.Root still wins over the one placement implies. Drawer.Title is set in text-xl, the same as Modal.Title. The positioner and content write the placement as data-placement, which the slide animation and the docked edge's border key on.
Prop
Type
Drawer.Root, Drawer.Trigger, and Drawer.Context render no DOM node (or styling) of their own, so none take a testId. Drawer.Backdrop, Drawer.Positioner, Drawer.Content, Drawer.Title, Drawer.Description, Drawer.Grabber, Drawer.Header, Drawer.Body, and Drawer.Footer each take their own testId, landing on their own rendered element. Drawer.CloseTrigger's testId routes to the actual rendered close button — an inner ActionIcon, since CloseTrigger itself is asChild over it — the same pattern as Modal.CloseTrigger. See Testing.
API
Prop
Type
All other props (snapPoints, closeThreshold, modal, trapFocus, …) forward to Ark's Drawer.Root.
Accessibility
- Same focus-trap, scroll-lock and focus-restore guarantees as
Modal— Ark's Drawer machine is a dialog under the hood. - A drawer needs an accessible name: a
title, aDrawer.Titleinside it, or anaria-label/aria-labelledby. Without one, a screen reader announces it as just "dialog", and the kit warns in the console during development. placementuses logical edges and CSS logical properties, so the panel and its slide animation mirror correctly underdir="rtl".- Swipe-to-dismiss is a progressive enhancement; keyboard and click paths work without it.
Changelog
- #383
Drawer parts live on the namespace only:
DrawerTitle,DrawerHeaderand the other flat exports becomeDrawer.Title,Drawer.Header… - #361
Swap any built-in icon through an
iconsmap —icons={{ asc, desc }}on DataTable,icons={{ show, hide }}on PasswordInput; a key you leave out keeps the kit's icon, and a part'schildrenstill win - #403
Composed drawers state their edge once:
Drawer.Root placementdocksDrawer.Positionerand sets the swipe direction, and the newDrawer.Contenttakessizeandradius - #403
The ready-made
<Drawer>takesrole="alertdialog"andradius, like Modal - #383
Drawer, Modal and
AppShell.Sidebaracceptaria-label/aria-labelledby, and development warns when an open dialog has no accessible name - #396
An open Modal or Drawer is a hotkey layer: hotkeys under it go quiet, and a Popover it was opened from stays open
- #331
A
translationsprop for the close, dismiss, collapse/expand and region labels;<Notifications />forwards its keys to every toast
- #251
An outside click no longer dismisses the parent while a nested overlay is open
- #135
--modal-zrises from 50 to 150, leaving room for the toast band below it
- #41
Floating surfaces take a brand tint
- #34
onClosefires alongsideonOpenChange, as on Modal
ModalandDrawer, controlled byopen/onOpenChange; Drawer slides in from any edge
Modal
Centered overlay dialog on Ark UI's Dialog machine — focus trap, scroll lock, RTL and animated enter/exit, with a flat props API and composable parts.
Overlays manager
Spawn modals and drawers imperatively from anywhere — content, confirm and typed context overlays — with one centralized, type-safe manager.