CSS Modal Generator
An overlay and a dialog box, styled with CSS.
The preview is a static picture of a modal, not a focus trap. When you build the real dialog, move keyboard focus into it, close it on Escape, and restore focus to the button that opened it.
Frequently asked questions
Should I use the dialog element?
Yes when you can. <dialog> gives you the top layer and a backdrop. These rules still style the box.
How do I center it?
The copy uses a fixed overlay with flex centering. The dialog is the child.