✨
Design System
Comprehensive component library with accessibility built-in.
Modern browsers provide a native modal element with built-in accessibility. Focus trap, Escape to close, and backdrop are all handled automatically!
Comprehensive component library with accessibility built-in.
Motion primitives respecting prefers-reduced-motion.
Interactive charts with keyboard navigation support.
| Feature | CSS :target | Vanilla JS | <dialog> |
|---|---|---|---|
| Focus Trap | ✗ | ✓ Manual | ✓ Native |
| Escape to Close | ✗ | ✓ Manual | ✓ Native |
| Backdrop | ✓ Manual | ✓ Manual | ✓ Native |
| Top Layer (above z-index) | ✗ | ✗ | ✓ Native |
| Return Focus | ✗ | ✓ Manual | ⚠ Manual |
| No JavaScript | ✓ | ✗ | ✗ |
| Browser Support | All | All | Modern* |
<!-- Native dialog element -->
<
dialog
id
=
"my-dialog"
> <
form
method
=
"dialog"
> <
h2
>Dialog Title</
h2
> <
p
>Content here...</
p
>
<!-- form method="dialog" auto-closes -->
<
button
value
=
"close"
>Close</
button
> </
form
> </
dialog
>
const
dialog = document.
getElementById
(
'my-dialog'
);
// Open as modal (with backdrop)
dialog.
showModal
();
// Open non-modal (no backdrop)
dialog.
show
();
// Close
dialog.
close
();
// Listen for close
dialog.
addEventListener
(
'close'
, () => { console.
log
(
'Dialog closed'
); });
/* Style the backdrop */
dialog::backdrop
{
background
:
rgba(0, 0, 0, 0.8)
;
backdrop-filter
:
blur(4px)
; }
/* Animate open state */
dialog[open]
{
animation
:
fadeIn 0.3s ease
; }
@keyframes fadeIn
{
from
{
opacity
:
0
; }
to
{
opacity
:
1
; } }