Centred modal for a short form or a confirmation. DialogFooter holds the actions.
Default
A short confirmation with a title, a sentence and two buttons.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add dialogIt needs no other component. The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/dialog.tsx.
import { DIALOG_MOTION, Dialog, DialogBody, DialogFooter } from "@/design-system/components/dialog";Usage
<Dialog open={open} onOpenChange={setOpen} title="Add client">
<form>…<DialogFooter><Button onClick={close}>Cancel</Button><Button type="submit" variant="primary">Add</Button></DialogFooter></form>
</Dialog>Examples
With a form
Fields inside the dialog; the first one gets focus when it opens.
Large
size="lg" for longer content; the body scrolls and the footer stays put.
Destructive
A red confirm button for something that can't be undone.
When to use
Use it when
- A short form: create, rename, add
- Confirming a destructive action
Don’t use it when
- Showing details beside the page → Drawer
- A list of actions → Dropdown menu
- Just a message → Alert or Toast
Rules
- Footer: Cancel (secondary) then the one primary action
- Put data-autofocus on the first field
- size lg for longer forms: the body scrolls, the footer stays
- size xl (880px) and hideTitle are for two-pane layouts such as settings-modal, which draw their own heading
- Opens and closes with motion: it fades, rises 8px and grows from 97% (280ms ease-smooth) and leaves the same way; reduced motion fades only. Reuse DIALOG_MOTION for any other native <dialog>
Properties
Dialog
| Prop | Type | Default |
|---|---|---|
open * | boolean | – |
onOpenChange * | (open: boolean) => void | – |
title * | string | – |
description | ReactNode | – |
children * | ReactNode | – |
size | "md" | "lg" | "xl" | "md" |
hideTitle | boolean | false |
className | string | – |
* required
Accessibility
- Native <dialog>: focus stays inside, Escape closes, focus returns to the trigger
Related
Used in the Avesk app: Design Inspiration, Projects & Clients.