Skip to content

Latest commit

 

History

History
102 lines (74 loc) · 2.04 KB

drawer.mdx

File metadata and controls

102 lines (74 loc) · 2.04 KB
title description component links
Drawer
A drawer component for React.
true

About

Drawer is built on top of Vaul by emilkowalski_.

Installation

CLI Manual
npx 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.

Usage

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>

Background Scaling

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>

Examples

Responsive Dialog

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.