Blazor playground

Nova v3.37.0

Preview

Blazor

Dialog

nv-dialog

A modal window over a dimmed page for a short, focused task that people finish or dismiss before they continue.

Live demo

Use a dialog for a short task that needs attention before people continue, such as a confirmation, an important message or a small form. While it is open, the page behind it is covered and can't be used. Don't open a dialog from another dialog.

Anatomy

A dialog titled Dialog Title on a dimmed overlay, with a message and two actions. Callouts mark 1 the header, 2 the body, 3 the footer, 4 the close button and 5 the overlay.

The parts of a dialog.
  1. Header (nv-dialogheader) holds a short title and an optional subheading.
  2. Body is the default slot: text, a form or other content.
  3. Footer (nv-dialogfooter) has a cancel and a primary action, which can be a danger action.
  4. Close button closes the dialog without saving. With undismissable, it is removed, Escape does nothing, and the footer needs its own undismissable to drop Cancel.
  5. Overlay covers the page. Clicking it closes the dialog only with clickOutside.

Sizes and themes

The design offers a regular dialog and a larger alternative. In code, the regular dialog sizes to its content within viewport limits; full gives it a wide, viewport-relative layout. There is no size enum. Both Spark and Ocean provide the dialog surface, overlay and action styles.

Customising the sections

Replace the header and footer slots independently, and put body content in the default slot. There is no named body slot. Keep the title and primary action easy to identify even when the content is a form or another custom layout. In Figma, give a replacement body component a fixed width so its parent dialog resizes correctly.

Use a dialog for confirmations, focused alerts or short forms. If an action inside it needs another confirmation, restructure the task rather than opening another modal.

Opening and closing

A button in the trigger slot opens the dialog. With controlled, the application opens it through open instead. Escape and the close button close it and update open. Cancel emits dialogCanceled: an uncontrolled dialog then closes itself, but a controlled one stays open until your application sets open to false. The primary action never closes the dialog; your application decides when the task is done.

  • Name actions after what they do, such as "Delete readings" or "Save name", not "OK" or "Done".
  • Keep the title short and use the subheading for context.
DoName each action after what it does.
Don'tAvoid generic labels such as “OK” or “Yes”.

Accessibility

The dialog uses the browser's modal dialog behaviour. Keep a meaningful title and a visible way to finish or dismiss the task, and preserve labelling when replacing the header. autofocus can opt into focusing the first focusable control; use it deliberately, especially when that control has a tooltip.

Sources