demo · v135

command + commandfor, no JS

Chrome 135 ships command and commandfor on <button>. Pick a built-in command from the menu — show-modal, toggle-popover, show-picker — and watch a real button drive a real dialog / popover without a single event listener.

command attribute: ?

I'm a real <dialog>.

I'm a popover. Click outside to dismiss.

event log

the code

<button commandfor="dlg" command="show-modal">open</button>
<dialog id="dlg">
  …
  <button commandfor="dlg" command="close">cancel</button>
</dialog>

see also