Dialog
Opens a short, focused task above the page, such as editing a record.
When to use
- A short, focused task that belongs to this page: edit a record, create an API key.
- Content that needs full attention before the user continues.
When not to use
- Confirming a destructive or irreversible action: use Alert Dialog.
- Filters or details next to the page: use Sheet.
- A brief confirmation after an action: use Sonner.
- A long, multi-step flow: give it its own page.
Install
npx shadcn@latest add @clinia/dialogAnatomy
Edit profile
Changes apply to every workspace you belong to.
- 1Container
data-slot="dialog-content"bg-popover · rounded-lg · p-6 - 2Title
data-slot="dialog-title"text-base · font-medium - 3Description
data-slot="dialog-description"text-sm · text-muted-foreground - 4Body
[data-part=body]Field - 5Footer
data-slot="dialog-footer"secondary first · main last - 6Close button
data-slot="dialog-close"ghost
Clinia rules
- The title is sentence case and names the task:
Edit profile. - The footer puts the secondary action first and the main action last (
Cancel, thenSave changes). It stacks with the main action on top on small screens. - One
defaultbutton per dialog, like any other view.
Do and don't
Edit source
Changes apply on the next sync.
Edit source
Changes apply on the next sync.
States
Edit profile
Changes apply to every workspace.
Edit profile
Changes apply to every workspace.
Edit profile
Changes apply to every workspace.
Invite members to Montreal clinic
Send invitations to one or more people. They get an email with a link to join.
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
Accessibility
Built in
- Focus moves into the dialog when it opens and stays inside until it closes.
- Escape and the close button close it, and focus returns to the element that opened it.
- The page behind is inert while the dialog is open.
Your responsibility
- Always render a
DialogTitle. AddDialogDescriptionwhen the title alone doesn't explain the task. - Open it from a real button, so focus has somewhere to return.
How to test
- Open it with the keyboard: focus lands inside the dialog.
- Press Tab repeatedly: focus cycles through the dialog and never reaches the page behind.
- Press Escape: it closes, and focus returns to the button that opened it.
- With a screen reader, opening it announces a dialog and its title.
API
DialogContent
| Prop | Values | Default | Description |
|---|---|---|---|
| showCloseButton | boolean | true | Shows the close button in the corner. Turn it off only when the footer has its own way out. |
DialogFooter
| Prop | Values | Default | Description |
|---|---|---|---|
| showCloseButton | boolean | false | Adds an outline "Close" button after the footer's children. Off by default. |
All other props come from Base UI Dialog.