# journey.dialog

{% hint style="info" %}
**Version compatibility**

`journey.dialog` was introduced with version **4.80.0** of the JourneyApps Runtime.
{% endhint %}

Dialogs appear as blocking overlays that provides information or confirms destructive behavior. They often prompt users to make a decision.

{% hint style="success" %}
These docs describe dialogs called from JavaScript/TypeScript. For more fully featured, dynamic dialogs, please refer to the [`dialog` UI component docs](https://docs.journeyapps.com/reference/build/ui-components/all-ui-components/dialog). These dialogs are specified from the view XML and can include nested components.
{% endhint %}

## Simple Dialog

Display a dialog with a message and one button.

| Property   | Description                                                                                                                                                                        | Example                                                                                                  |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `title`    | Heading displayed on the dialog                                                                                                                                                    |                                                                                                          |
| `message`  | Main message displayed in the dialog                                                                                                                                               |                                                                                                          |
| `okButton` | <p>Dialog's OK button. This can either be a string or an object with <code>text</code> and <code>color</code> as fields. </p><p></p><p>Returns <code>true</code> when clicked.</p> | <p><code>okButton: "Done"</code><br>or<br><code>okButton: { text: "Done", color: "positive" }</code></p> |

Example:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2FsseUq8IJOpCM5OEYmd7x%2FScreen%20Shot%202022-10-07%20at%209.50.28%20AM.png?alt=media\&token=d89b12d7-3f47-46ed-8683-d653dd4407f8)

{% code title="main.js" %}

```javascript
journey.dialog.simple({
    title: "Success",
    message: "You have successfully submitted the form.",
    okButton: "Done"
});
```

{% endcode %}

## Confirm Dialog

Display a dialog with a message prompting the user to accept or cancel.

| Property       | Description                                                                                                                                                                             | Example                                                                                                              |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `title`        | Heading displayed on the dialog                                                                                                                                                         |                                                                                                                      |
| `message`      | Main message displayed in the dialog                                                                                                                                                    |                                                                                                                      |
| `okButton`     | <p>Dialog's OK button. This can either be a string or an object with <code>text</code> and <code>color</code> as fields. </p><p></p><p>Returns <code>true</code> when clicked.</p>      | <p><code>okButton: "Confirm"</code><br>or<br><code>okButton: { text: "Confirm", color: "positive" }</code></p>       |
| `cancelButton` | <p>Dialog's Cancel button. This can either be a string or an object with <code>text</code> and <code>color</code> as fields. </p><p></p><p>Returns <code>false</code> when clicked.</p> | <p><code>cancelButton: "Cancel"</code><br>or<br><code>cancelButton: { text: "Cancel", color: "negative" }</code></p> |

Example:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2F5UeXjIQ5mFLpsulg608u%2FScreen%20Shot%202022-10-07%20at%209.51.21%20AM.png?alt=media\&token=f58fd3c1-5868-4c1b-ab36-868301f260ee)

{% code title="main.js" %}

```javascript
journey.dialog.confirm({
    title: "Confirm your submission",
    message: "Are you sure you want to submit this form?",
    okButton: { text: "Confirm", color: "positive" },
    cancelButton: "Cancel"
});
```

{% endcode %}

## Input Dialog

Display a dialog with a message and a `text-input` for simple data entry.

{% hint style="info" %}
For more advanced composition dialogs, see the [dialog component](https://docs.journeyapps.com/reference/build/ui-components/all-ui-components/dialog) documentation.
{% endhint %}

| Property       | Description                                                                                                                                                                                                                                                                                                                                                           | Example                                                                                                              |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `title`        | Heading displayed on the dialog                                                                                                                                                                                                                                                                                                                                       |                                                                                                                      |
| `message`      | Main message displayed in the dialog                                                                                                                                                                                                                                                                                                                                  |                                                                                                                      |
| `saveButton`   | <p>Dialog's Save button. This can either be a string or an object with <code>text</code> and <code>color</code> as fields. </p><p></p><p>Returns the entered value as a <code>string</code> when clicked.</p>                                                                                                                                                         | <p><code>saveButton: "Save"</code><br>or<br><code>saveButton: { text: "Save", color: "positive" }</code></p>         |
| `cancelButton` | <p>Dialog's Cancel button. This can either be a string or an object with <code>text</code> and <code>color</code> as fields. </p><p></p><p>Returns <code>undefined</code> when clicked.</p>                                                                                                                                                                           | <p><code>cancelButton: "Cancel"</code><br>or<br><code>cancelButton: { text: "Cancel", color: "negative" }</code></p> |
| `inputLabel`   | Label for the input component                                                                                                                                                                                                                                                                                                                                         |                                                                                                                      |
| `inputType`    | <p>Type of input required from the user. Can be one of the following types (reference: <a href="https://www.w3schools.com/html/html_form_input_types.asp">HTML Input Types</a>): </p><ul><li><code>email</code></li><li><code>number</code></li><li><code>paragraph</code></li><li><code>password</code></li><li><code>tel</code></li><li><code>text</code></li></ul> | `text`                                                                                                               |
| `inputValue`   | Current value set for the input component                                                                                                                                                                                                                                                                                                                             |                                                                                                                      |

Example:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2FvjEkFhpXjenrIfgcP7MW%2FScreen%20Shot%202022-10-07%20at%209.46.01%20AM.png?alt=media\&token=71dc49e8-c9e5-4ea9-9c82-fefb6d3cfbc9)

<pre class="language-javascript" data-title="main.js"><code class="lang-javascript">journey.dialog.input({
<strong>    title: "Please enter your name",
</strong>    message: "Enter your first and last names",
    inputLabel: "Answer",
    inputType: "text",
    inputValue: "",
    saveButton: "Save",
    cancelButton: "Cancel"
});
</code></pre>

## Error Dialog

Display a dialog with only a message and one button to indicate an error state.

| Property   | Description                                                                                                                                                                        | Example                                                                                                    |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `title`    | Heading displayed on the dialog                                                                                                                                                    |                                                                                                            |
| `message`  | Main message displayed in the dialog                                                                                                                                               |                                                                                                            |
| `okButton` | <p>Dialog's OK button. This can either be a string or an object with <code>text</code> and <code>color</code> as fields. </p><p></p><p>Returns <code>true</code> when clicked.</p> | <p><code>okButton: "Close"</code><br>or<br><code>okButton: { text: "Close", color: "negative" }</code></p> |

Example:

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2F3g6s0pWA5X9ZrfbXY2Wq%2FScreen%20Shot%202022-10-07%20at%209.47.51%20AM.png?alt=media\&token=89f7d8f6-aaf9-4abe-96f2-97757a73933b)

{% code title="main.js" %}

```javascript
journey.dialog.error({
    title: "Submit Failed",
    message: "Failed to submit the form, please check validations and retry",
    okButton: "OK"
});
```

{% endcode %}

## Styling Options

{% hint style="info" %}
**Version compatibility**

Styling options were introduced in version **4.89.17** of the JourneyApps Runtime.
{% endhint %}

The style of buttons within these dialogs can be customized as follows.

Example:

<pre class="language-javascript" data-title="main.js"><code class="lang-javascript"><strong>
</strong>await journey.dialog.error({
      title: 'Alert', 
      message:'My message', 
      okButton: {
            text: 'OK',
            color: 'cyan',
            textColor: "black",
            icon: 'fa-cube',
            iconColor: 'orange',
            labelCapitalization: 'uppercase'
     }
})
</code></pre>
