Dialog

A native modal dialog with a title, local triggers and focus return.

Opening, closing and Escape stay local; focus returns to the trigger.

Open in new tab

Each preview is its own Live page in a frame, because this site is a Vue 3.5 app built on the Pulsar starter kit. An open list or popover stays inside its frame; in your application it opens over the page.

Installation

bash
suprnova live:add dialog

Usage

html
{% import "suprnova-ui/dialog/dialog.html" as dialog %}
{% call dialog::dialog_trigger("about", "About") %}{% endcall %}{% call dialog::dialog("about", "about", "About this app") %}{% call dialog::dialog_close("about") %}{% endcall %}{% endcall %}

Examples

Server confirmation

Archive a demo in your island; the dialog stays open to show the server answer.

Open in new tab

Keyboard and accessibility

suprnova.dialog - a native modal dialog (OVL-001). dialog_trigger opens it and dialog_close closes it through the sn-dialog element; the dialog element owns the open state, focus containment and Escape, and focus returns to the trigger on close (OVL-005). Keyed and preserved across a compatible morph (OVL-006). The host carries tabindex="-1" so it can take focus when the trigger has left the document.

API reference

dialog_trigger

ParameterDefaultDescription
targetRequiredThe modal's `id` to open locally.
textRequiredThe trigger's visible text.
variant"primary"The button variant: `primary`, `secondary`, `ghost` or `danger`.

dialog

ParameterDefaultDescription
idRequiredThe native dialog's `id`, also used to associate its title and triggers.
keyRequiredA stable `live:key` that preserves the browser-owned open state across compatible morphs.
titleRequiredThe visible heading, associated with the dialog through `aria-labelledby`.

dialog_close

ParameterDefaultDescription
targetRequiredThe modal's `id` to close locally, returning focus to its invoker.
text"Close"The close button's visible text.
variant"secondary"The button variant: `primary`, `secondary`, `ghost` or `danger`.