Skip to main content

Documentation 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.

The 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 the Dialog object for chaining.
Dialog.append(content)
content
Node | string
required
The content to append. Accepts any value valid for jQuery’s append()—HTML strings, DOM nodes, jQuery objects, etc.
returns
Dialog
The Dialog object, for method chaining.
If your content contains Tea/SugarCube wiki markup (e.g., //italics// or ''bold''), use Dialog.wiki() instead. Dialog.append() treats its argument as raw HTML, not wiki markup.
Dialog.append("Cry 'Havoc!', and let slip the <em>dogs</em> of <strong>war</strong>.");

Dialog.body()

Returns a reference to the dialog’s body HTMLElement.
Dialog.body()
returns
HTMLElement
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.
jQuery(Dialog.body())
  .append("Cry 'Havoc!', and let slip the <em>dogs</em> of <strong>war</strong>.");

jQuery(Dialog.body())
  .wiki("Cry 'Havoc!', and let slip the //dogs// of ''war''.");

Dialog.close()

Closes the currently open dialog. Returns the Dialog object for chaining.
Dialog.close()
returns
Dialog
The Dialog object, for method chaining.
Dialog.close();

Dialog.create()

Prepares the dialog for use by setting its title and optional CSS class names. Returns the Dialog object for chaining.
Dialog.create([title [, classNames]])
title
string
The title to display in the dialog’s title bar. Pass null or omit to show no title.
classNames
string
A space-separated list of CSS class names to add to the dialog element, useful for targeting specific dialogs with custom styles.
returns
Dialog
The Dialog object, for method chaining.
Dialog.create();

Dialog.empty()

Empties the dialog’s body element, removing all content. Returns the Dialog object for chaining.
Dialog.empty()
returns
Dialog
The Dialog object, for method chaining.
Dialog.empty();
You can chain Dialog.empty() to replace the content of an already-open dialog:
Dialog
  .empty()
  .wikiPassage('Quests');

Dialog.isOpen()

Returns whether the dialog is currently open. When classNames is provided, also checks that the open dialog has all of those classes.
Dialog.isOpen([classNames])
classNames
string
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).
returns
boolean
true if the dialog is open (and matches the given classes, if provided).
if (Dialog.isOpen()) {
  /* code to execute if any dialog is open… */
}

Dialog.open()

Opens the dialog. Should be called after populating the dialog with content. Returns the Dialog object for chaining.
Dialog.open([options [, closeFn]])
options
object
Options controlling dialog presentation. Pass null to skip.
options.top
number
default:"50"
Top y-coordinate of the dialog in pixels, without a unit suffix.
closeFn
Function
A callback executed every time the dialog is closed.
returns
Dialog
The Dialog object, for method chaining.
Dialog.open();

Dialog.wiki()

Renders wiki markup and appends the result to the dialog’s body. Returns the Dialog object for chaining.
Dialog.wiki(wikiMarkup)
wikiMarkup
string
required
The Tea/SugarCube wiki markup string to render.
returns
Dialog
The Dialog object, for method chaining.
If your content consists of DOM nodes rather than markup strings, use Dialog.append() instead.
Dialog.wiki("Cry 'Havoc!', and let slip the //dogs// of ''war''.");

Dialog.wikiPassage()

Renders a named passage and appends the result to the dialog’s body. Returns the Dialog object for chaining.
Dialog.wikiPassage(passageName)
passageName
string
required
The name of the passage to render into the dialog body.
returns
Dialog
The Dialog object, for method chaining.
Dialog.wikiPassage('Inventory');

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.
Dialog
  .create('Character Sheet', 'charsheet')
  .wikiPassage('Player Character')
  .open({ top: 80 }, () => {
    console.log('Character sheet closed.');
  });
If the dialog is already open and you want to swap its content without reopening it, use Dialog.empty() followed by a content method:
Dialog
  .empty()
  .wikiPassage('Quests');
This is useful for multi-page dialog flows where you want to update what is displayed without the close/reopen animation.

Build docs developers (and LLMs) love