- Accordion
- Action BarUpdated
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- BadgeUpdated
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- CalendarUpdated
- CardUpdated
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context MenuUpdated
- Data List
- Date Picker
- DialogUpdated
- DrawerUpdated
- Editable
- FieldUpdated
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- MarqueeUpdated
- Menu
- Native Select
- Number InputUpdated
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- TableUpdated
- Tabs
- Textarea
- TimerUpdated
- ToastUpdated
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Drawer
A sliding panel with swipe support.
Edit Profile
Installation#
pnpm dlx shadcn@latest add @shark/drawer
Anatomy#
Drawer ├── DrawerTrigger └── DrawerContent ├── DrawerGrabber ├── DrawerContentInner │ ├── DrawerHeader │ └── DrawerBody └── DrawerFooter └── DrawerClose
Usage#
import { Drawer, DrawerTrigger, DrawerContent, DrawerContentInner, DrawerHeader, DrawerTitle, DrawerDescription, DrawerBody, DrawerFooter, DrawerClose, } from "@/components/ui/drawer";
<Drawer> <DrawerTrigger /> <DrawerContent> <DrawerContentInner> <DrawerHeader> <DrawerTitle /> <DrawerDescription /> </DrawerHeader> <DrawerBody> {/** your content here */} </DrawerBody> </DrawerContentInner> <DrawerFooter> <DrawerContentInner> <DrawerClose /> </DrawerContentInner> </DrawerFooter> </DrawerContent> </Drawer>
Examples#
Container#
Use DrawerContentInner to constrain drawer content width to max-w-sm.
Container
Inset Variant#
Use variant="inset" on DrawerContent so the drawer appears as a floating card rather than edge-to-edge.
Inset drawer
Swipe Directions#
Control which direction the drawer slides and swipes using swipeDirection on the root.
Bottom Drawer
Swipe down to close this drawer.
Top Drawer
Swipe up to close this drawer.
Start Drawer
Swipe left to close this drawer.
End Drawer
Swipe right to close this drawer.
Snap Points#
Use snapPoints to allow the drawer to snap to multiple heights.
Snap Points
This drawer has multiple snap points. Try dragging the handle to quarter, half, or full height.
Custom spacing#
Use [--space:--spacing("value")] on DrawerContent to adjust internal spacing.
Default spacing is --spacing(6).
Custom spacing
You can use breakpoint utilities to change the internal spacing at different screen sizes.
md:[--space:--spacing(6)] lg:[--space:--spacing(8)]
API Reference#
Drawer#
Root element of the drawer.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | ({ open }: OpenChangeDetails) => void | - |
swipeDirection | "up" | "down" | "left" | "right" | "down" |
snapPoints | (number | string)[] | [1] |
defaultSnapPoint | number | string | null | 1 |
snapToSequentialPoints | boolean | false |
closeThreshold | number | 0.25 |
swipeVelocityThreshold | number | 700 |
preventDragOnScroll | boolean | true |
modal | boolean | true |
closeOnEscape | boolean | true |
closeOnInteractOutside | boolean | true |
className | string | - |
DrawerTrigger#
Opens the drawer on click. Use asChild for custom trigger elements.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
DrawerContent#
Holds the drawer panel. Supports swipe-to-close; direction inherited from root swipeDirection.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "inset" | "default" |
className | string | - |
| Attribute | Default |
|---|---|
--bleed | 3rem |
--space | --spacing(4) |
DrawerContentInner#
Wrapper that constrains content to max-w-sm and centers it. Use to wrap the main body (header + body) or footer actions. When used inside DrawerFooter, inherits flex-col-reverse and gap-2 for button layout.
| Prop | Type | Default |
|---|---|---|
className | string | - |
DrawerHeader#
Header area for title and description. Accepts props or children.
| Prop | Type | Default |
|---|---|---|
title | string | - |
description | string | - |
className | string | - |
DrawerTitle#
Accessible title for the drawer. Announced to screen readers.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
DrawerDescription#
Accessible description for the drawer. Announced to screen readers.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
DrawerBody#
Scrollable body content. Uses ScrollArea for overflow. Supports scrollFade for gradient edges.
| Prop | Type | Default |
|---|---|---|
scrollFade | boolean | false |
className | string | - |
DrawerFooter#
Footer area for action buttons.
| Prop | Type | Default |
|---|---|---|
className | string | - |
DrawerClose#
Closes the drawer on click. Use asChild for custom close elements.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
For a complete list of props, see the Ark UI documentation.