|Kit

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, a Drawer.Title inside it, or an aria-label / aria-labelledby. Without one, a screen reader announces it as just "dialog", and the kit warns in the console during development.
  • placement uses logical edges and CSS logical properties, so the panel and its slide animation mirror correctly under dir="rtl".
  • Swipe-to-dismiss is a progressive enhancement; keyboard and click paths work without it.

Changelog

v0.30.0
  • Modal.Body and Drawer.Body scroll in a ScrollArea, and className lands on the scrolled content: to turn the body's scroll off, pass scrollable={false} instead of overflow-hidden

    #494
  • scrollable={false} on Modal, Drawer and their Body gives a plain body for content that has its own scroller

    #494
v0.20.0
  • Drawer parts live on the namespace only: DrawerTitle, DrawerHeader and the other flat exports become Drawer.Title, Drawer.Header…

    #383
  • Swap any built-in icon through an icons map — icons={{ asc, desc }} on DataTable, icons={{ show, hide }} on PasswordInput; a key you leave out keeps the kit's icon, and a part's children still win

    #361
  • Composed drawers state their edge once: Drawer.Root placement docks Drawer.Positioner and sets the swipe direction, and the new Drawer.Content takes size and radius

    #403
  • The ready-made <Drawer> takes role="alertdialog" and radius, like Modal

    #403
  • Drawer, Modal and AppShell.Sidebar accept aria-label/aria-labelledby, and development warns when an open dialog has no accessible name

    #383
  • An open Modal or Drawer is a hotkey layer: hotkeys under it go quiet, and a Popover it was opened from stays open

    #396
v0.19.0
  • A translations prop for the close, dismiss, collapse/expand and region labels; <Notifications /> forwards its keys to every toast

    #331
v0.18.0
  • asChild is a compile error on Combobox.Control, Group, Content, Panel and Item, Drawer/Modal.Positioner, Drawer.Grabber, Popover.Content and Tooltip.Arrow

    #294
  • CloseTrigger asChild uses your element in place of the icon button, without the forced aria-label

    #288
v0.16.0
  • An outside click no longer dismisses the parent while a nested overlay is open

    #251
v0.9.0
  • --modal-z rises from 50 to 150, leaving room for the toast band below it

    #135
v0.4.0
  • Floating surfaces take a brand tint

    #41
v0.3.0
  • onClose fires alongside onOpenChange, as on Modal

    #34
v0.0.1
  • Modal and Drawer, controlled by open/onOpenChange; Drawer slides in from any edge

On this page