Trên trang này

Trang này chưa có bản tiếng Việt, nội dung bên dưới là bản tiếng Anh. Xem trang tiếng Anh

Dialog

When to use a dialog, what to use instead, button order, behaviour and tokens.

Draft. Ported from control-center’s Dialog (from shadcn-vue) and restyled with Beehexa tokens, 12 November 2026. Not yet approved. It is in the registry so teams can try it; the API may still change before approval.

A dialog is a window over the page. While it is open, the page behind is dimmed and can’t be used. People finish the task in it or cancel.

When to use

  • For a short task that should not lose its place on the page: edit a connection, add a note, invite a person.
  • To show details that need more room than a popover, without leaving the page.

When not to use

  • To confirm a can’t-undo action. Use an alert dialog: it can’t be closed by a click outside.
  • For a long form or a task people come back to. Use a page, or a sheet beside the content.
  • For a few controls tied to one button. Use a popover.
  • For a message that needs no answer. Use a toast or an inline message.
  • On top of another dialog. Change the content of the open one instead.

Buttons

  • Right-aligned. The primary action is last, Cancel just before it (D10). Write them in that order in DialogFooter.
  • One primary action at most. Name it with a verb and its object: “Save changes”, not “OK”.
  • On narrow screens the buttons stack, primary on top.
  • show-close-button on DialogFooter adds a Close button, for dialogs with nothing to save.

Behaviour

  • Opens on its trigger. Focus moves to the first field or control in the dialog and stays inside it until it closes.
  • Closes on Esc, a click on the scrim, the close button in the corner, or a button in the footer. Focus returns to the trigger.
  • Centred, 512 px wide at most (size.dialog.default), and 16 px clear of the window edge on phones. Set another width with class when the content needs it.
  • DialogScrollContent lets a tall dialog scroll as a whole.

Content

  • A title that says what the dialog is for, in a few words: “Edit connection”.
  • A description only when it adds something: what happens on save, or what is not changed.

Tokens

Part Tokens
Scrim color.surface.scrim
Surface color.surface.overlay, elevation.shadow.modal
Layer z-index.modal
Corners radius.modal (12 px)
Padding, gap space.modal (24 px), space.modal.gap
Title font.heading.medium, color.text
Description font.body.default, color.text.subtle
Footer On the dialog surface, no band or line, space.modal.gap below the body; 8 px between buttons
Close button Subtle icon button, size.control.small, in the corner space.modal from the edges