Control dialogs with button commands

Limited support Reference ↗

command and commandfor let a button open or close a dialog declaratively. The relationship lives in HTML instead of a click handler.

<button commandfor="info" command="show-modal">
  Open details
</button>

<dialog id="info">
  <p>Native dialog, declarative controls.</p>
  <button commandfor="info" command="close">
    Close
  </button>
</dialog>  

Support is still limited. If opening the dialog is essential, provide a tested fallback rather than assuming the command will run everywhere.