Talisman LogoTalisman Logo Design System
Browse documentation
Components

Dialog

A modal window that interrupts the flow for a decision or a short task, and requires a response before returning.

Stableimport { Dialog } from "@repo/ui/dialog";Source

Select the button to open the dialog. Press Escape or use the footer to close it.

When to use

  • To confirm an action that is hard to undo.
  • To collect a few fields without leaving the current page.
  • To stop the flow when something needs an answer before it can continue, such as an expiring session.

When not to use

  • Long forms or multi-step tasks. Use a Drawer or a Sheet, or a page.
  • Messages that need no answer. Use an Alert or a toast.
  • Help text for a control. Use a Tooltip or a Popover.
  • Anything the user may want to read while working elsewhere. A modal blocks the page.

Anatomy

A dialog is built from parts. Always include a title and a way out.

Part Role
Dialog Holds the open state.
DialogTrigger The element that opens it. Use asChild with a Button.
DialogContent The panel and its dark backdrop. Adds the corner × unless hidden.
DialogHeader Groups the title and the description.
DialogTitle Names the dialog. Required for assistive technology.
DialogDescription One or two sentences of context.
DialogFooter The actions. Supporting action first, main action last.
DialogClose Closes the dialog. Use asChild on the cancel button.

Examples

Confirm a decision

State what will happen and who is affected. Name the action on the button.

Destructive confirmation

Use the critical variant on the confirm button and say what will be lost.

Short form

Without the corner button

Content

  • Write the title as the question or the result: “Excluir a tarefa?”, not “Atenção”.
  • The description adds consequences, not repetition of the title.
  • Buttons name the action: “Excluir tarefa”, “Enviar para revisão”. Avoid “Sim” and “OK”.
  • Put the main action on the right, the cancel action on its left.

Do and don’t

DoName the object and the consequence, and offer a clear way out.
Don'tDon't use vague buttons. The user has to reread the dialog to understand them.

Accessibility

  • Built on Radix Dialog: focus moves into the dialog on open, stays inside it, and returns to the trigger on close.
  • Escape closes the dialog and the page behind it cannot be reached.
  • DialogTitle names the dialog and DialogDescription describes it, so both are read when it opens. Never leave them out.
  • The corner × is labelled “Close”. Pass translated copy with closeLabel.
  • If you use hideCloseButton, the footer must always offer a way to close.

Code

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@repo/ui/dialog";
import { Button } from "@repo/ui/button";

<Dialog>
  <DialogTrigger asChild>
    <Button variant="secondary">Revisar contestação</Button>
  </DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Enviar contestação para revisão?</DialogTitle>
      <DialogDescription>O revisor recebe o documento agora.</DialogDescription>
    </DialogHeader>
    <DialogFooter>
      <DialogClose asChild>
        <Button variant="secondary">Cancelar</Button>
      </DialogClose>
      <Button variant="primary">Enviar para revisão</Button>
    </DialogFooter>
  </DialogContent>
</Dialog>;

Props

Dialog
PropTypeDefaultDescription
defaultOpenbooleanfalseInitial open state when the dialog is uncontrolled
modalbooleantrueBlocks interaction with the rest of the page while open
onOpenChange(open: boolean) => void—Called when the dialog opens or closes
openboolean—Controlled open state
DialogContent
PropTypeDefaultDescription
hideCloseButtonbooleanfalseHides the corner × button.
closeLabelstring"Close"Accessible name of the corner button. Pass translated copy from the app.
overlayClassNamestring—Extra class for the backdrop.
DialogTrigger, DialogClose
PropTypeDefaultDescription
asChildbooleanfalseRenders the child element instead of a button, for DialogTrigger and DialogClose.

Known issues

Issue Effect
The backdrop is bg-black/80, a translucent fill. The repository avoids transparency in UI. A solid token or a blur-free overlay is not available yet.
The corner × has no padding: its hit target is 16px. Below the 24px minimum. Harder to hit with a mouse and on touch screens.
DialogTitle and DialogDescription use raw classes instead of Typography. The text styles do not follow the type scale tokens.
The close button uses ring-offset-background and bg-accent. Depends on tokens from the old color system.
Edit this page on GitHub