Skip to content

Dialog

Stable

A modal window on the native dialog element, with a title, a body that scrolls and a footer for buttons.

Also known as modal, modal dialog, popup window, alert dialog

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Confirm with a footer

The simplest use: a title, a line of context and two buttons. The main action goes last.

When to use it

Stops the person to ask for a decision or a small amount of input that must be settled before they go on. Everything behind it is locked until it closes.

Made of: Backdrop · Panel · Danger label (destructive only) · Title · Description · Close button · Body · Footer

Use it for

  • Confirming an action that is hard to undo, such as deleting a project.
  • A short form that must be finished before moving on.
  • Long content that should stay out of the page until asked for, such as terms.

Not for

  • A message that does not need an answer: use Toast.
  • A note that stays on the page: use Callout.
  • A short list of choices next to a button: use Popover.
  • A menu of actions for one item: use ToolMenu.

Do and avoid

Delete this trip?

Your bookings stay, but the plan is gone.

Do. Stops people only for a choice they must make now.

Saved

Your trip was saved.

Avoid. A pop-up for news with nothing to decide just blocks the way.

Do

  • Keep the open value in your own code and set it to false in onClose.
  • Name the footer buttons after what they do.
  • Put one clear main action in the footer and make the way out equally easy to find.
  • Keep the body short. If it needs a full page, make it a page.
  • Use tone destructive for actions that cannot be undone.

Avoid

  • Do not open a Dialog for a message that needs no answer. Use a Toast or a Callout.
  • Do not stack one Dialog on top of another.
  • Do not use it for a short list of choices. Use a Popover or a menu.
  • Do not set dismissible to false unless leaving without choosing would cause harm.
  • Do not rely on the red tone alone to warn. The label and your wording must say it too.

On a phone

  • On a phone the dialog opens from the bottom as a sheet with rounded top corners; from 640px it is centered.
  • It is at most 90% of the screen height, the body scrolls inside, and scrolling does not pass through to the page.
  • The footer buttons stack in a column on a phone, sit side by side from 640px, and stay clear of the bottom safe area.
  • Tapping the backdrop closes it unless you made it not dismissible.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started