Dialog
Free
An accessible modal that springs in over a blurred backdrop and hands focus back on close.
Danger zone
Delete this project
Removes Mosswood Dashboard and everything in it.
Customize
Backdrop closes
Installation
npx shadcn@latest add https://ui.mekaigames.com/r/dialog.jsonWorks in any project set up with the shadcn CLI.
Install the dependency.
npm install motion- Copy the code from the Code tab into
components/ui/dialog.tsx.
Usage
import { useState } from "react";
import { Dialog } from "@/components/ui/dialog";
export function DeleteProject() {
const [open, setOpen] = useState(false);
return (
<>
<button onClick={() => setOpen(true)}>Delete project</button>
<Dialog
open={open}
onOpenChange={setOpen}
title="Delete project"
description="This can't be undone."
>
<button onClick={() => setOpen(false)}>Cancel</button>
<button onClick={deleteProject}>Delete</button>
</Dialog>
</>
);
}Props
9 properties| Property | Type | Default | Description |
|---|---|---|---|
| open | boolean | — | Whether the dialog is shown. |
| onOpenChange | (open: boolean) => void | — | Called with false on Escape, backdrop click or the close button. |
| title | ReactNode | — | Heading, also the dialog's accessible name. |
| description | ReactNode | — | Supporting text, announced with the title. |
| children | ReactNode | — | Body and actions. Focus starts on the first focusable element, or on one marked data-autofocus. |
| closeOnBackdrop | boolean | true | Close when the backdrop is clicked. Escape always closes. |
| showClose | boolean | true | Show the close button in the corner. |
| container | HTMLElement | null | document.body | Portal target. An element keeps the dialog inside it; null waits until it exists. |
| className | string | — | Extra classes for the panel. |
Dependencies: motion