This demo shows a modal dialog that is closed by default. Click the button below to open it.
Additional content to demonstrate background scroll-lock and focus trapping.
You can also from here.
This is a modal dialog. It traps keyboard focus while open and can be closed by pressing Escape, clicking outside on the overlay, or using the close button.
Try tabbing around to see focus constrained within the dialog. A demo link is also focusable.