A modal window that focuses the user on a single task.
$ pnpm dlx shadcn@latest add https://dashral.com/r/dialog.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/dialog.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/dialogUsage
import { Button } from "@/components/dashral/button"
import { Input } from "@/components/dashral/input"
import { Dialog, DialogClose } from "@/components/dashral/dialog"
<Dialog
trigger={<Button variant="outline">Edit profile</Button>}
title="Edit profile"
description="Your team sees the change at once."
form={{ action: api.profile.update }}
footer={
<>
<DialogClose asChild>
<Button variant="outline">Cancel</Button>
</DialogClose>
<Button type="submit">Save</Button>
</>
}
>
<Input label="Name" name="name" defaultValue="Olivia Martin" />
</Dialog>Examples
API reference
Dialog
Also takes every prop of Radix Dialog(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
trigger | ReactElementWhat opens it. Leave it out to open it with open / onOpenChange. | — |
title | ReactNodeRequired: it names the dialog. Hide it with classNames.title "sr-only" if the design has none. | — |
description | ReactNodeUnder the title; it describes the dialog. | — |
children | ReactNodeThe body. | — |
footer | ReactNodeButtons at the bottom. | — |
form | ComponentProps<"form">Makes the body and footer one form, e.g. { onSubmit } or { action }. | — |
size | "sm" | "md" | "lg" | "xl"The window's width. | "md" |
showCloseButton | booleanThe × in the corner. | true |
open / defaultOpen / onOpenChange | Controlled or initial state. | — |
classNames | { header, title, description, footer }Classes for each part. | — |
className | stringThe window's classes. | — |
DialogClose
Closes the dialog: wrap a Cancel button in the footer.
Also takes every prop of Radix Dialog(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
asChild | booleanRender the child element instead (e.g. a Next.js Link), passing these styles and props to it. | false |
Keyboard
| Keys | Action |
|---|---|
| TaborShift+Tab | Move between controls; focus stays inside while it's open |
| Escape | Close and return focus to what opened it |
Accessibility
- role="dialog" with aria-modal, labelled by its title and described by its description.
- The rest of the page is inert while it's open.
Motion
- The window springs in from 95% with a soft blur clearing; the backdrop fades in and blurs the page a little. Closing is quicker.