Dialog
catnip-dialog renders a modal dialog using the native <dialog> element with Catnip header, body, and footer structure. Use it for focused decisions, confirmations, short forms, and interruptive flows that must temporarily block the page behind it.
The prop-based header supports title, description, icon, and centered layout. Put actions in the footer slot; replace the header with the header slot when you need custom structure. padding="none" removes the default surface inset; --catnip-dialog-padding sets a custom length. --catnip-dialog-width overrides the t-shirt size (including max-content to hug content).
catnip-dialog is controlled by open. Close actions emit close-dialog and update:open, but the dialog stays open until the consumer updates open to false.
Live example
Accessibility
- Opens with
showModal(), setsaria-modal="true", and blocks background interaction. - Moves focus into the dialog, relies on native
showModal()focus containment, uses a fallback Tab trap only when native modal opening is unavailable, supports Escape dismissal whenclosable=true, and restores focus after close. - Uses generated
aria-labelledby/aria-describedbyIDs whentitleanddescriptionprops are used. - When using the
headerslot, provide an accessible name witharia-labeloraria-labelledby. after-dialog-closefires afteropen=falsehas removed the rendered dialog tree.