title | description | component | links |
---|---|---|---|
Drawer |
A drawer component for React. |
true |
Drawer is built on top of Vaul by emilkowalski_.
CLI Manualnpx shadcn@latest add drawer
Install the following dependencies:
npm install vaul
Copy and paste the following code into your project.
Update the import paths to match your project setup.
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer"
<Drawer>
<DrawerTrigger>Open</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Are you absolutely sure?</DrawerTitle>
<DrawerDescription>This action cannot be undone.</DrawerDescription>
</DrawerHeader>
<DrawerFooter>
<Button>Submit</Button>
<DrawerClose>
<Button variant="outline">Cancel</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
You can get the background to zoom and scale when the drawer is open by adding the data-vaul-drawer-wrapper=""
attribute to the root component of your application.
<div id="app" data-vaul-drawer-wrapper="">
{children}
</div>
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.