Dialog
A puffy modal card. In kawaii mode it drops in from above, squashes as it lands, kicks dust out of both bottom corners and throws stars off the top.
Installation
❯ npx shadcn@latest add https://yan.moe/r/dialog.jsonUsage
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"<Dialog>
<DialogTrigger>Open</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Share your last mochi?</DialogTitle>
<DialogDescription>You can always buy another one tomorrow.</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>Use DialogFooter for actions and wrap any button in DialogClose asChild to make it close the dialog.
Accessibility
- Built on Radix Dialog: focus is trapped inside, Escape and a backdrop click close it, and focus returns to the trigger.
- Always include a
DialogTitle; add aDialogDescriptionwhen the title alone is not enough. - With
prefers-reduced-motion: reduce, the drop, the dust and the stars are skipped.
API
| Prop | Type | Default |
|---|---|---|
intensitySet on DialogContent. kawaii: drop, squash, dust and stars. subtle: fade in. off: just appear. | "kawaii" | "subtle" | "off" | "kawaii" |
fxSet on DialogContent. Overrides for the opening burst. | BurstOptions | - |
hideCloseSet on DialogContent. Hide the round close button in the corner. | boolean | false |
open / defaultOpenSet on Dialog. Controlled and uncontrolled state. | boolean | - |
onOpenChangeSet on Dialog. Called when it opens or closes. | (open: boolean) => void | - |