Dialog Panel
A lightweight wrapper around native <dialog> with state-driven animations. The primitive the sheets sit on.
v2.0.3@magic-spells/dialog-panel
Live demo
last result: —
Open it, then answer or dismiss it — the readout shows which button closed it, or “dismissed” for Escape and the backdrop.
About
A lightweight web component wrapper for native `` elements with state-driven animations.
Features
- Zero dependencies - Uses native `` for focus trapping and accessibility
- Lightweight - ~3.4kb minified
- State-driven animations - CSS transitions based on state attribute
- One overlay surface - Always style ``; the same rule holds in every package
- Accessible - Native dialog handles focus trap, escape key, and ARIA
- Nested dialogs - Proper stacking and event isolation
Usage
<button id="open-btn">Open Dialog</button>
<dialog-panel id="my-dialog">
<dialog aria-labelledby="dialog-title">
<div class="dialog-content">
<h2 id="dialog-title">Hello!</h2>
<p>This is a modal dialog.</p>
<button data-action-hide-dialog>Close</button>
</div>
</dialog>
</dialog-panel>
<script>
const dialog = document.getElementById('my-dialog');
document.getElementById('open-btn').addEventListener('click', (e) => {
dialog.show(e.target);
});
</script>About, features, usage and options are taken from the package README.