Modal dialog component (example)
This example uses the native <dialog> element. The dialog is closed by default, and opening it moves focus into the dialog.
Closing it returns focus to the button that opened it.
Notes
- Press Escape to close the dialog.
- The “Close dialog” button also closes it.
- Submitting the form demonstrates inline error messaging and focus management.