Command Palette

Search for a command to run...

Drawer

A panel that slides out from the edge of the screen. A replacement for dialog on mobile and tablet.

Installation

npm i vaul

Usage

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer" export function DrawerDemo() { return ( <Drawer> <DrawerTrigger>Open</DrawerTrigger> <DrawerContent> <div className="mx-auto w-full max-w-sm"> <p className="text-center text-sm text-muted-foreground"> This drawer component uses Vaul behind the scenes. </p> </div> </DrawerContent> </Drawer> ) }

Examples

With Components

Different Positions

Note: The drawer will open from the direction specified. For example, "Top" means the drawer will slide down from the top of the screen.

Props

ComponentPropsDescription
DrawerDrawerPrimitive.RootProps
shouldScaleBackground?: boolean
direction?: 'top' | 'bottom' | 'left' | 'right'
The root component for the drawer. Set direction to change the position of the drawer.
DrawerTriggerDrawerPrimitive.TriggerProps
asChild?: boolean
The button that opens the drawer.
DrawerContentDrawerPrimitive.ContentPropsThe container for the drawer content.
DrawerHeaderReact.HTMLAttributes<HTMLDivElement>Contains the title and description of the drawer.
DrawerTitleDrawerPrimitive.TitlePropsThe title of the drawer.
DrawerDescriptionDrawerPrimitive.DescriptionPropsThe description of the drawer.
DrawerFooterReact.HTMLAttributes<HTMLDivElement>Used for aligning actions at the bottom of the drawer.
DrawerCloseDrawerPrimitive.CloseProps
asChild?: boolean
The button that closes the drawer.