Skip to content

Dialog

Download .md

A dialog asks for a decision or a short input in a window over the page, which stays dimmed behind it.

  • Use it for a short form or a choice that needs the whole attention, such as renaming a release.
  • Use an Alert Dialog to confirm an action that can’t be undone.
  • Use a Toast to confirm something that already happened.
  • Don’t put long flows in a dialog; use a page.
React
Vue
DoKeep a dialog to one decision or a short form.
Don'tDon't open a dialog on top of another dialog.
1234
  1. 1Overlay
  2. 2Title
  3. 3Body
  4. 4Actions, primary last

Title, description, optional content, then actions in the footer. The window sits on popover with a border, radius-xl (16px) and shadow-lg. The page behind it is dimmed with the overlay token.

There is one style. Put the main action last in the footer.

React Vue Flutter Type Default Use
open / defaultOpen v-model:open / default-open showShadDialog boolean false Whether it is open.
onOpenChange @update:open return value of showShadDialog function none Runs when it opens or closes.
DialogTrigger render DialogTrigger as-child onPressed element button The control that opens it.
import { useId } from "react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Field, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
export default function DialogDemo() {
const id = useId()
return (
<Dialog>
<DialogTrigger render={<Button variant="outline" />}>Ubah judul</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Ubah judul rilis</DialogTitle>
<DialogDescription>Judul baru tampil di semua toko musik setelah dikirim ulang.</DialogDescription>
</DialogHeader>
<Field>
<FieldLabel htmlFor={`${id}-title`}>Judul rilis</FieldLabel>
<Input id={`${id}-title`} defaultValue="Senja di Kota" />
</Field>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>Batal</DialogClose>
<DialogClose render={<Button />}>Simpan</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/dialog.json

The button it installs is the Sosialoka button.

  • Renders role="dialog" with the title as its name; focus moves into the dialog and returns to the trigger when it closes.
  • Escape closes it, and focus stays inside while it is open.