The simplest usage. The browser handles top-layer rendering, focus trapping, and Escape-to-close automatically. returnValue is set by form method="dialog".
Open the modal and try these — no JavaScript needed for any of them:
CSS-only entry and exit animation using @starting-style and transition-behavior: allow-discrete. Both the dialog and the frosted-glass backdrop animate smoothly.
The trick to animating dialog exit is allow-discrete — it lets the transition run even as the element leaves the top layer.
Override position: fixed; inset: 0 auto 0 0 to pin the dialog to the left edge. Full focus trapping and Escape key still work — no extra JavaScript needed.
Just three property changes convert any centered modal into a side drawer:
When a <form method="dialog"> submits, the dialog closes and dialog.returnValue is set to the clicked button's value. No JavaScript needed to close.