Installation
pnpm dlx shadcn@latest add https://neobrutalism.dev/r/drawer.jsonUsage
import { Button } from '@/components/ui/button'
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from '@/components/ui/drawer'<Drawer>
<DrawerTrigger render={<Button />}>Open</DrawerTrigger>
<DrawerContent>
<div className="mx-auto w-[300px]">
<DrawerHeader>
<DrawerTitle>Are you absolutely sure?</DrawerTitle>
<DrawerDescription>This action cannot be undone.</DrawerDescription>
</DrawerHeader>
<DrawerFooter className="grid grid-cols-2">
<Button variant="noShadow">Submit</Button>
<DrawerClose render={<Button className="bg-secondary-background text-foreground" variant="noShadow" />}>
Cancel
</DrawerClose>
</DrawerFooter>
</div>
</DrawerContent>
</Drawer>Examples
Default
With Scrollable Content
To make a region of the drawer scrollable, make the scroll container a flex item. Avoid h-full, which does not resolve inside a content-sized drawer.
Position
Use the swipeDirection prop to set the side of the drawer. Available options are up, right, down, and left.
Swipe Handle
Use showSwipeHandle on Drawer to render a swipe handle.
Nested
Open drawers from inside another drawer. Parent drawers stay mounted and stack behind the frontmost drawer.
Non Modal
Set modal={false} to allow interaction with the rest of the page while the drawer is open. Combine with disablePointerDismissal to prevent the drawer from closing on outside presses. Use modal="trap-focus" to keep focus inside the drawer while leaving scroll and pointer interaction unrestricted.
Snap Points
Use snapPoints to snap a drawer to preset heights. Numbers between 0 and 1 represent fractions of the viewport. Numbers greater than 1 are treated as pixel values. String values support px and rem units. Snap points apply to vertical drawers.
Track the active snap point with the controlled snapPoint and onSnapPointChange props. At the full snap point, the drawer gets a data-expanded attribute you can style with the data-expanded: variant.
Responsive
You can combine the Dialog and Drawer components to create a responsive dialog. This renders a Dialog component on desktop and a Drawer on mobile.