Default
Installation
templui add dialogLoad the script once in your layout:
<head>
@dialog.Script()
</head>Examples
External Trigger
Non-modal
API Reference
Dialog
Main dialog wrapper component. Provides context for child components.
| Name | Type | Default |
|---|---|---|
Optional HTML id for the dialog root. Useful for external targeting. | | |
Additional CSS classes to apply to the dialog container | | |
Additional HTML attributes to apply to the dialog container | | |
Whether to disable closing the dialog by clicking outside | | |
Whether to disable closing the dialog with the ESC key | | |
Whether the dialog should be open initially | | |
Trigger
Element that triggers the dialog to open. Usually used inside Dialog, or externally by targeting a dialog root ID with For.
| Name | Type | Default |
|---|---|---|
Unique identifier for the trigger element | | |
Additional CSS classes to apply to the trigger | | |
Additional HTML attributes to apply to the trigger | | |
Optional dialog root id for external triggers | | |
Content
Native dialog content rendered inside Dialog.
| Name | Type | Default |
|---|---|---|
Additional CSS classes to apply to the content | | |
Additional HTML attributes to apply to the content | | |
Whether to hide the default close button | | |
Whether to disable modal mode (removes the backdrop) | | |
Header
Header section of the dialog.
| Name | Type | Default |
|---|---|---|
Unique identifier for the header element | | |
Additional CSS classes to apply to the header | | |
Additional HTML attributes to apply to the header | | |
Title
Dialog title component. Should be used inside Header.
| Name | Type | Default |
|---|---|---|
Unique identifier for the title element | | |
Additional CSS classes to apply to the title | | |
Additional HTML attributes to apply to the title | | |
Description
Dialog description component. Should be used inside Header.
| Name | Type | Default |
|---|---|---|
Unique identifier for the description element | | |
Additional CSS classes to apply to the description | | |
Additional HTML attributes to apply to the description | | |
Body
Body/content section of the dialog.
| Name | Type | Default |
|---|---|---|
Unique identifier for the body element | | |
Additional CSS classes to apply to the body | | |
Additional HTML attributes to apply to the body | | |
Close
Element that closes the dialog.
| Name | Type | Default |
|---|---|---|
Unique identifier for the close element | | |
Additional CSS classes to apply to the close element | | |
Additional HTML attributes to apply to the close element | | |
Optional dialog root id to close (defaults to closest dialog if empty) | | |
JavaScript API
// Open a dialog programmatically
window.tui.dialog.open("dialog-root-id");
// Close a dialog
window.tui.dialog.close("dialog-root-id");
// Toggle dialog state
window.tui.dialog.toggle("dialog-root-id");
// Check if dialog is open (returns true/false)
const isOpen = window.tui.dialog.isOpen("dialog-root-id");