Dialog
Introduction
An overlay modal container that halts normal user interaction with the page to gather explicit input, showcase vital dashboard tools, or request action confirmations.
The Dialog component is fully integrated as a dialog block in the Page Builder, enabling content managers to easily define structural triggers (such as clicking an action button), titles, custom footer menus, and modal text directly inside Sveltia CMS.
Hydration & Interactive Behavior
A Dialog requires a client-side JavaScript engine to manage critical accessibility behavior, focus trapping, and keyboard controls. As a result, the dialog hydrates as an active client island by default. If a static, read-only presentation wrapper is desired, set "interactive": false to prevent loading client-side script assets.
| JSON Property | Hydration Mode | Description |
|---|---|---|
"interactive": true | Interactive Island (Default) | Fully responsive modal with focus trapping, Escape closures, and overlay dimming. |
"interactive": false | Static HTML Template | A server-rendered static layout shell with no interactive javascript behavior. |
Usage
These configurations represent exactly how page-builder block items are constructed.
1. Action Confirmation Modal
A standard confirmation dialog triggered via an action button, complete with cancel and accept options. Ideal for simple choices like checking settings or confirming items.
{
"type": "dialog",
"title": "Confirm Account Sync",
"description": "Are you sure you want to merge workspace details?",
"body": "This syncs configurations across devices. Unsaved local changes might be overridden.",
"confirmText": "Synchronize",
"cancelText": "Dismiss",
"trigger": [
{
"type": "button",
"text": "Trigger Action Modal",
"colorPalette": "blue"
}
]
}
Confirm Account Sync
Confirm Account Sync
2. Destructive Action Alert (Alertdialog Role)
Use this format for high-consequence, irreversible destructive confirmations (e.g., deleting a database or discarding unsaved work). This configuration changes the dialog's semantic screen role to alertdialog.
{
"type": "dialog",
"role": "alertdialog",
"title": "Destroy Database",
"description": "You are about to permanently erase production server nodes.",
"body": "This operation is immediate and completely irreversible. All live connections will instantly shut down.",
"confirmText": "Erase Forever",
"cancelText": "Keep Database",
"trigger": [
{
"type": "button",
"text": "Delete Database",
"colorPalette": "red"
}
]
}
Destroy Database
Destroy Database
Props
| Property | CMS Field Type | Default | Description / Supported Options |
|---|---|---|---|
Trigger Element (trigger) | list | - | Block items (such as Buttons or Links) that render on the page to open the dialog upon click. |
Heading (title) | string | - | The bold title header text displayed at the top of the dialog card. |
Subheading (description) | string | - | Supplementary subheader text providing secondary explanation context. |
Body Content (body) | string | - | The primary descriptive text or layout content blocks rendering within the card's middle region. |
Confirm Action Text (confirmText) | string | - | Optional. Text label for the main action confirmation button. |
Cancel Action Text (cancelText) | string | - | Optional. Text label for the close/dismiss action button. |
Role Type (role) | select | "dialog" | Semantic role of the modal. • "dialog" — Standard interactive window. • "alertdialog" — Destructive warnings. |
Custom Footer (footer) | list | - | List of blocks rendered on the lower edge. Ideal for custom controls or additional button shortcuts. |
Enable Hydration (interactive) | boolean | true | When true, hydrates the component as a client-side island to enable overlays, focus trap, and Escape closures. |
Accessibility & Developer Notes
Complies with the Dialog (Modal) WAI-ARIA design pattern. When hydrated, the component implements the following critical accessibility layers:
- Initial Focus Trap: Focus shifts into the dialog on open (selecting the cancel/safe action first to avoid accidental triggers) and remains trapped internally while scrolling with
Tab/Shift + Tab. - Background Inertia: Interactive elements outside the open modal container are automatically marked with the HTML
inertattribute to prevent screen readers or keyboard controls from focusing on elements behind the backdrop. - Escape Close Handling: Pressing the
Escapekeyboard button automatically shuts the active dialog container (unlesscloseOnEscapeis configured otherwise). - Body Scroll Locking: Document body scrolling is frozen while a modal is active and automatically restored once the dialog has completed its close transition.