Drawer
Slides in from any edge on a spring; its grip stretches while you drag it.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/drawerThis adds components/keyframery/drawer.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Drawer, DrawerBackdrop, DrawerContent, DrawerGrip, DrawerHeader, DrawerTitle, DrawerTrigger } from "@/components/keyframery/drawer"
export default function Usage() {
return (
<Drawer>
<DrawerTrigger>Open</DrawerTrigger>
<DrawerBackdrop />
<DrawerContent>
<DrawerGrip />
<DrawerHeader>
<DrawerTitle>Title</DrawerTitle>
</DrawerHeader>
</DrawerContent>
</Drawer>
)
}Anatomy
How the parts fit together:
Drawer
├── DrawerTrigger
├── DrawerBackdrop
└── DrawerContent
├── DrawerGrip
└── DrawerHeader
└── DrawerTitleExamples
Basic
Slides up from the bottom. Drag the grip down, press Escape or tap outside to close it.
Snap points
snapPoints lets it rest part way up, like a map's place list. Drag between them.
From the side
side="right" slides it in from the edge, for a cart or a details panel.
Motion
| Move | What you see |
|---|---|
| Spring | The sheet slides in from its edge on a spring and follows your finger while dragged. |
| Cascade | Its contents arrive one after another once it is open. |
| Stretch | The grip stretches while you drag. |
Timing and springiness follow the motion style you set. To change how fast this drawer moves, pass speed:
<Drawer speed="fast">
…
</Drawer>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--drawer-face | Drawer sheet and overscroll strip | --popover |
--drawer-ink | Drawer body text | --popover-foreground |
--drawer-accent | Primary action and hover mix | --primary |
--drawer-width | Sheet maximum width | 480px top/bottom; 380px left/right |
--drawer-radius | Free-edge corners | 18px |
--drawer-gap | Footer key spacing | 0.5rem |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK drawer reference.
Drawer
Prop
Type
DrawerTrigger
Renders a <button>, and takes its props too.
Prop
Type
DrawerContent
Renders a <div>, and takes its props too.
Prop
Type
DrawerClose
Renders a <button>, and takes its props too.
Prop
Type
DrawerOutlet
Renders a <div>, and takes its props too.
Prop
Type
DrawerShortcut
Renders a <span>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
DrawerBackdrop: a<div>DrawerGrip: a<div>DrawerHeader: a<div>DrawerTitle: a<h2>DrawerDescription: a<p>DrawerFooter: a<div>DrawerHandle: a<button>
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves between the drawer's controls. Focus stays inside. |
| Escape | Closes the drawer. |
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's drawer with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/drawer"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/drawer"Questions
How does the animated Drawer for UI SDK move?
Spring: The sheet slides in from its edge on a spring and follows your finger while dragged. Cascade: Its contents arrive one after another once it is open. Stretch: The grip stretches while you drag.
Do I need Motion or Framer Motion for the animated Drawer?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/drawer instead. It has the same parts and props as @ui-sdk/react/drawer and adds motion only.
What happens to the Drawer when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.