Ship faster with goilerplate templUI Pro

Dialog

Dialog overlay that requires user attention or interaction.

Source Tailwind CSS JavaScript

Default

Edit Profile

Make changes to your profile here. Click save when you're done.

Installation

  1. Install the component

    templui add dialog
  2. Add the JavaScript to your layout

    @dialog.Script()
    

    Call this template in your base layout file (e.g., in the <head> section).

Examples

External Trigger

External Dialog

This dialog can be triggered from anywhere on the page.

Standalone Content

Standalone Dialog

This dialog content works without a wrapper component.

Perfect for dynamic content loading with HTMX or similar frameworks.

API Reference

Required parameter
Hover for description

Dialog

Main dialog wrapper component. Provides context for child components.

Name Type Default
ID
string
randomID
Class
string
""
Attributes
templ.Attributes
nil
DisableClickAway
bool
false
DisableESC
bool
false
Open
bool
false

Trigger

Element that triggers the dialog to open. Can be used inside Dialog wrapper or externally with For prop.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil
For
string
""

Content

Dialog content container. Can be used standalone for HTMX or inside Dialog wrapper.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil
HideCloseButton
bool
false
Open
bool
false
DisableAutoFocus
bool
false

Title

Dialog title component. Should be used inside Header.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil

Description

Dialog description component. Should be used inside Header.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil

Body

Body/content section of the dialog.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil

Close

Element that closes the dialog.

Name Type Default
ID
string
""
Class
string
""
Attributes
templ.Attributes
nil
For
string
""

JavaScript API

// Open a dialog programmatically
window.tui.dialog.open("dialog-id");

// Close a dialog
window.tui.dialog.close("dialog-id");

// Toggle dialog state
window.tui.dialog.toggle("dialog-id");

// Check if dialog is open (returns true/false)
const isOpen = window.tui.dialog.isOpen("dialog-id");