<wmcp-dialog>

A modal dialog wrapping the native <dialog> element — so it inherits the platform's focus trap, top-layer stacking, backdrop, and Escape-to-close for free. The exposed action is open: an agent can surface the dialog for the user to review, but closing and confirming stay a deliberate human step.

That asymmetry is the point. An agent can ask for attention; the irreversible confirm is the person's to make. It's the same consent gate the form controls draw between setting a value and submitting it.

<wmcp-dialog name="booking" label="Confirm booking" expose>
  <h3>Confirm your booking</h3>
  <p>Book Tuesday, 3:00 PM with Dr. Reyes?</p>
  <wmcp-button variant="ghost" onclick="this.closest('wmcp-dialog').close()">Cancel</wmcp-button>
  <wmcp-button variant="primary">Confirm</wmcp-button>
</wmcp-dialog>

Element attributes

AttributeTypeDefaultDescription
openbooleanfalseWhether the dialog is open (reflected — drives [open] styling).
modalbooleantrueOpen as a focus-trapping modal with a backdrop. Set false for a non-modal dialog.
static-backdropbooleanfalseKeep the dialog open when the backdrop is clicked.
labelstringAccessible name for the dialog, and the noun in the default tool description.
namestringIdentifier used for the default tool name (open_<name>).
exposebooleanfalseRegister a WebMCP tool that opens this dialog.
tool-namestringOverride the generated tool name.
tool-descriptionstringOverride the generated tool description.

Methods, events & properties

MemberKindDescription
show()methodOpen the dialog (modal unless modal is false).
close(returnValue?)methodClose it, optionally recording a returnValue.
returnValuepropertyThe value the dialog last closed with (mirrors native <dialog>).
open eventeventFired (composed) when the dialog opens.
close eventeventFired (composed) when it closes — via close(), Escape, or backdrop.

Tool shape

Like every interaction primitive, the exposed tool takes no arguments — calling it opens the dialog:

{
  "type": "object",
  "properties": {}
}

Calling the tool on an already-open dialog is a no-op that reports as much; it never closes the dialog (closing is never the agent's call).

Theming

Every visual is a CSS custom property defaulting through the design tokens to the shadcn popover palette, including the backdrop:

:root {
  --dialog-bg: var(--popover);
  --dialog-radius: 1rem;
  --dialog-backdrop: color-mix(in oklch, black 60%, transparent);
}

The entrance fade-and-lift uses @starting-style and transition-behavior: allow-discrete, and is suppressed under prefers-reduced-motion.