A panel that slides out from the edge of the screen.
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer" import { Button } from "@/components/ui/button" export function DrawerDemo() { return ( <Drawer> <DrawerTrigger asChild> <Button variant="outline">Open Drawer</Button> </DrawerTrigger> <DrawerContent> <div className="mx-auto w-full max-w-sm"> <DrawerHeader> <DrawerTitle>Edit profile</DrawerTitle> <DrawerDescription> Make changes to your profile here. Click save when you're done. </DrawerDescription> </DrawerHeader> <div className="p-4"> <p className="text-sm text-muted-foreground"> Your drawer content goes here. </p> </div> <DrawerFooter> <Button>Save changes</Button> <DrawerClose asChild> <Button variant="outline">Cancel</Button> </DrawerClose> </DrawerFooter> </div> </DrawerContent> </Drawer> ) }
Prop | Type | Default | Description |
---|---|---|---|
open | boolean | - | Whether the drawer is open. |
onOpenChange | function | - | Function called when the open state of the drawer changes. |
shouldScaleBackground | boolean | true | Whether the background should scale when the drawer is opened. |