Dialog
Props
| Prop | Type | Default | Options | Description |
|---|---|---|---|---|
| open | boolean | false | — | Controls whether the dialog is open |
| size | "s" | "m" | "l" | "m" | s, m, l | Dialog width: 492px, 664px, 836px. Override with --catnip-dialog-width. |
| padding | string | "default" | default, none | Surface inset. none removes it. Override with --catnip-dialog-padding for a custom length. |
| layout | "default" | "centered" | "default" | default, centered | Controls alignment of the generated header, body content, and footer actions |
| dialogRole | string | "dialog" | dialog, alertdialog | ARIA role |
| dialogTitle | string | "" | — | Header title; ignored when the header slot is used |
| description | string | "" | — | Header description; ignored when the header slot is used |
| icon | CatnipIconName | "" | "" | Valid CatnipIconName | Header icon; ignored when the header slot is used |
| iconSize | number | 32 default / 40 centered | — | Header icon size in px; an explicit value overrides the layout default |
| intent | string | "brand" | informative, success, warning, danger, brand | Semantic color treatment for the generated header icon |
| showCloseButton | boolean | true | — | Shows the header close button |
| backdropBlur | boolean | false | — | Adds blur to the backdrop |
| closeOnBackdropClick | boolean | false | — | Requests dismissal after a backdrop click only when closable is also true |
| closable | boolean | true | — | Allows implicit dismissal requests through Escape and backdrop clicks |
| dialogAriaLabel | string | "" | — | Accessible name override |
| ariaLabelledby | string | "" | — | ID of the labelling element |
| ariaDescribedby | string | "" | — | ID of the describing element |
| closeButtonAriaLabel | string | "Close dialog" | — | Accessible name for the icon-only close button |
| testSelectors | TestSelectorsProp | See Test Selectors | — | Overrides stable data-test values. |
Slots
| Name | Description |
|---|---|
| header | Custom header content. Header props are ignored when this slot has content. |
| (default) | Dialog body. Rendered only while the dialog is open. |
| footer | Footer actions. Consumers own buttons, hierarchy, and whether an action updates open. |
Events
| Event | Description |
|---|---|
| update:open | Emitted with false when the dialog requests dismissal; consumers must update open |
| close-dialog | Emitted when close button, Escape, backdrop, or native close requests dismissal |
| backdrop-click | Emitted whenever the backdrop is clicked |
| after-dialog-close | Emitted after the dialog is closed and removed from the rendered tree |
catnip-dialog is controlled by open. Dismissal actions emit close-dialog and update:open=false, but the dialog remains visible until the consumer updates open to false.
Use layout="centered" when the dialog's generated header, body copy, and footer actions should be centered.
When closable=false, Escape never requests dismissal and backdrop clicks only emit backdrop-click, even when closeOnBackdropClick=true. Users can still request dismissal through the generated header close button when showCloseButton=true. Footer actions are consumer-owned and should update open directly. If neither an explicit close control nor a footer action is available, consumers must close the dialog programmatically.
Width
The predefined size widths are s = 492px, m = 664px, and l = 836px. Set --catnip-dialog-width on the host to override the selected desktop size. The effective width is capped at the viewport.
catnip-dialog {
--catnip-dialog-width: 720px;
}To hug content instead of a t-shirt size, set the same variable to max-content (still capped at the viewport):
catnip-dialog {
--catnip-dialog-width: max-content;
}At the mobile breakpoint the surface always uses the near-full viewport width, including when a custom width is set.
Padding
Default surface padding is 40px (--catnip-space-10), 24px below 560px. Set padding="none" to remove it. For a custom inset, set --catnip-dialog-padding on the host (same pattern as the width override):
catnip-dialog {
--catnip-dialog-padding: 16px;
}Test Selectors
| Attribute | Default Value |
|---|---|
root | catnip-dialog |
surface | catnip-dialog-surface |
header | catnip-dialog-header |
icon | catnip-dialog-icon |
title | catnip-dialog-title |
description | catnip-dialog-description |
body | catnip-dialog-body |
footer | catnip-dialog-footer |
closeButton | catnip-dialog-close |