Drawer
A panel that slides up from the bottom of the screen, for touch devices.
When to use
- A short task on a touch screen, opened from the bottom: share a record, pick one action.
- A panel users expect to dismiss with a swipe.
When not to use
- A panel next to the page on desktop: use Sheet.
- A focused task on desktop: use Dialog.
- Confirming a destructive action: use Alert Dialog.
Install
npx shadcn@latest add @clinia/drawerAnatomy
Share this record
Anyone in the workspace with the link can open it.
- 1Drawer
data-slot="drawer-popup"bg-popover · rounded-lg · m-2 - 2Swipe handle (optional)
data-slot="drawer-swipe-handle"bg-input · aria-hidden - 3Title
data-slot="drawer-title"text-base · font-medium - 4Description
data-slot="drawer-description"text-sm · text-muted-foreground - 5Footer
data-slot="drawer-footer"full-width buttons · main on top
Clinia rules
- It slides up from the bottom by default and closes with a swipe down (
swipeDirection). If you don't need the gesture, use Dialog or Sheet. showSwipeHandleadds the swipe handle in theinputtoken.- The footer stacks full-width buttons: the main action on top, Cancel below.
- Header text centres on a bottom drawer and aligns left from
mdup.
Do and don't
Share this record
Anyone in the workspace with the link can open it.
Share this record
Anyone in the workspace with the link can open it.
Accessibility
Built in
- Built on Base UI Drawer, which extends Dialog: focus moves into the drawer and stays inside, Escape closes it, and focus returns to the trigger.
- The swipe handle uses the
inputtoken so it stays visible. It isaria-hidden: a pointer affordance only.
Your responsibility
- Always render a
DrawerTitle. AddDrawerDescriptionwhen the title alone doesn't explain the task. - Put a
DrawerClosebutton labelled Cancel in the footer: not everyone can swipe, and a touch screen has no Escape key.
How to test
- Open it with the keyboard: focus lands inside the drawer.
- Press Escape: it closes, and focus returns to the button that opened it.
- On a phone, swipe down: it closes. Cancel does the same.
- With a screen reader, opening it announces a dialog and its title.
API
| Prop | Values | Default | Description |
|---|---|---|---|
| showSwipeHandle | boolean | false | Shows the drag handle at the top. Keep a Cancel button too: not every user can swipe. |
All other props come from Base UI Drawer.
Related