TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
Dialog API is the low-level interface Tea uses to display all of its modal dialogs—alerts, saves, settings, and restart prompts—and the same API is available for your own custom dialogs. The typical workflow is: call Dialog.create() to set a title and CSS classes, populate the dialog body with Dialog.wiki(), Dialog.wikiPassage(), or Dialog.append(), then call Dialog.open() to show it to the player.
Most methods return a reference to the Dialog object itself, so you can chain the entire setup in a single expression.
Dialog.append()
Appends content to the dialog’s body element. Returns theDialog object for chaining.
The content to append. Accepts any value valid for jQuery’s
append()—HTML strings, DOM nodes, jQuery objects, etc.The
Dialog object, for method chaining.Dialog.body()
Returns a reference to the dialog’s bodyHTMLElement.
The dialog’s body element.
In most cases you can use
Dialog.append() or Dialog.wiki() instead of working with the body element directly. Dialog.body() is useful when you need to pass the element to jQuery or vanilla DOM methods.Dialog.close()
Closes the currently open dialog. Returns theDialog object for chaining.
The
Dialog object, for method chaining.Dialog.create()
Prepares the dialog for use by setting its title and optional CSS class names. Returns theDialog object for chaining.
The title to display in the dialog’s title bar. Pass
null or omit to show no title.A space-separated list of CSS class names to add to the dialog element, useful for targeting specific dialogs with custom styles.
The
Dialog object, for method chaining.- No arguments
- Title only
- Class names only
- Title and class
Dialog.empty()
Empties the dialog’s body element, removing all content. Returns theDialog object for chaining.
The
Dialog object, for method chaining.Dialog.empty() to replace the content of an already-open dialog:
Dialog.isOpen()
Returns whether the dialog is currently open. WhenclassNames is provided, also checks that the open dialog has all of those classes.
A space-separated list of CSS class names. When provided, returns
true only if the dialog is open and has all specified classes. Each built-in dialog includes a name-themed class (e.g., the Saves dialog has the class saves).true if the dialog is open (and matches the given classes, if provided).- Any dialog
- Specific dialog
Dialog.open()
Opens the dialog. Should be called after populating the dialog with content. Returns theDialog object for chaining.
Options controlling dialog presentation. Pass
null to skip.Top y-coordinate of the dialog in pixels, without a unit suffix.
A callback executed every time the dialog is closed.
The
Dialog object, for method chaining.- Basic usage
- With position
- With close callback
Dialog.wiki()
Renders wiki markup and appends the result to the dialog’s body. Returns theDialog object for chaining.
The Tea/SugarCube wiki markup string to render.
The
Dialog object, for method chaining.Dialog.wikiPassage()
Renders a named passage and appends the result to the dialog’s body. Returns theDialog object for chaining.
The name of the passage to render into the dialog body.
The
Dialog object, for method chaining.Complete example
The following shows the full pattern for creating and opening a custom dialog from JavaScript. All four steps can be chained into a single expression.Replacing an open dialog's content
Replacing an open dialog's content
If the dialog is already open and you want to swap its content without reopening it, use This is useful for multi-page dialog flows where you want to update what is displayed without the close/reopen animation.
Dialog.empty() followed by a content method: