Skip to content
Drivn logoDrivn

Dialog

Modal dialog with overlay, escape key, and click-outside to close.

Preview

Confirm Action

Are you sure you want to continue? This action cannot be undone.

Installation

npx drivn add dialog

Usage

1import { Dialog } from "@/components/ui/dialog"
2import { Button } from "@/components/ui/button"
3
4export default function Page() {
5 return (
6 <Dialog>
7 <Dialog.Trigger>Open Dialog</Dialog.Trigger>
8 <Dialog.Content title="Confirm Action">
9 <Dialog.Close />
10 <p>Are you sure you want to continue?</p>
11 <Button>Confirm</Button>
12 </Dialog.Content>
13 </Dialog>
14 )
15}

API Reference

Dialog

PropTypeDefaultDescription
openbooleanControlled open state. Omit for uncontrolled mode.
onOpenChange(open: boolean) => voidCallback fired when the dialog open state changes
childrenReactNodeDialog sub-components (Trigger, Content, Close)

Dialog.Content

PropTypeDefaultDescription
titlestringOptional heading displayed at the top of the dialog
classNamestringAdditional CSS classes to apply to the dialog panel
childrenReactNodeContent rendered inside the dialog body