---
title: "Modals"
manual: "TYPO3 Explained"
version: "11.5"
permalink: "https://docs.typo3.org/permalink/t3coreapi:modules-modals@11.5"
source: "ApiOverview/JavaScript/Modules/Modals.rst"
rendered: "2026-10-21T15:30:00+00:00"
---

> [!WARNING]
> **Attention**
>
> TYPO3 v11 has reached end-of-life as of October 31th 2024 and
> is no longer being maintained. Use the version switcher on the top
> left of this page to select documentation for a supported version of TYPO3.
>
> Need more time before upgrading?
> You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here:
> [TYPO3 ELTS](https://typo3.com/services/extended-support-elts).

# Modals {#modules-modals}

Actions that require a user's attention must be visualized by modal windows.

TYPO3 provides an API as basis to create modal windows with severity
representation. For better UX, if actions (buttons) are attached to the modal,
one button must be a positive action. This button should get a `btnClass`
to highlight it.

Modals should be used rarely and only for confirmations. For information that
does not require a confirmation
the [Notification API (flash message)](https://docs.typo3.org/permalink/t3coreapi:flash-messages-javascript@11.5) should be used.

For complex content, like forms or a lot of information, use normal pages.

## API {#api}

The API provides only two public methods:

1.  `TYPO3.Modal.confirm(title, content, severity, buttons)`
1.  `TYPO3.Modal.dismiss()`

### Modal settings {#modules-modals-settings}

-   **title**

    -   *Required:* true
    -   *type:* string

    The title displayed in the modal

-   **content**

    -   *Required:* true
    -   *type:* string|jQuery

    The content displayed in the modal

-   **severity**

    -   *type:* int
    -   *Default:* `TYPO3.Severity.info`

    Represents the severity of a modal. Please see `TYPO3.Severity`.

-   **buttons**

    -   *type:* object\[\]

    Actions rendered into the modal footer. If empty, the footer
    is not rendered. See section [Modals](https://docs.typo3.org/permalink/t3coreapi:modules-modals@11.5) on how to configure the buttons.

### Button settings {#modules-modals-button-settings}

-   **text**

    -   *Required:* true
    -   *type:* string

    The text rendered into the button.

-   **trigger / action**

    -   *Required:* true
    -   *type:* function

    Callback that is triggered on button click - either a simple function or
    `DeferredAction` / `ImmediateAction`

-   **active**

    -   *type:* bool

    Marks the button as active. If true, the button gets the focus.

-   **btnClass**

    -   *type:* string

    The CSS class for the button.

### Data Attributes {#data-attributes}

It is also possible to use `data` attributes to trigger a modal,
for example on an anchor element, which prevents the default behavior.

-   **`data-title`**

    The title text for the modal.

-   **`data-bs-content`**

    The content text for the modal.

-   **`data-severity`**

    The severity for the modal, default is `info` (see `TYPO3.Severity.*`).

-   **`data-href`**

    The target URL, default is the `href` attribute of the element.

-   **`data-button-close-text`**

    Button text for the **close**/**cancel** button.

-   **`data-button-ok-text `**

    Button text for the **ok** button.

-   **`class="t3js-modal-trigger"`**

    Marks the element as modal trigger.

Example:

```html
<a
    href="delete.php"
    class="t3js-modal-trigger"
    data-title="Delete"
    data-bs-content="Really delete?"
>
    delete
</a>

```

## Examples {#examples}

A basic modal (without anything special) can be created this way:

```javascript
TYPO3.Modal.confirm('The title of the modal', 'This the the body of the modal');
```

A modal as warning with button:

```javascript
TYPO3.Modal.confirm('Warning', 'You may break the internet!', TYPO3.Severity.warning, [
  {
    text: 'Break it',
    active: true,
    trigger: function() {
      // break the net
    }
  }, {
    text: 'Abort!',
    trigger: function() {
      TYPO3.Modal.dismiss();
    }
  }
]);

```

A modal as warning:

```javascript
TYPO3.Modal.confirm('Warning', 'You may break the internet!', TYPO3.Severity.warning);
```

Action buttons in modals created by the `TYPO3/CMS/Backend/Modal` module may
make use of `TYPO3/CMS/Backend/ActionButton/ImmediateAction` and
`TYPO3/CMS/Backend/ActionButton/DeferredAction`.

As an alternative to the existing `trigger` option, the option
`action` may be used with an instance of the previously mentioned modules.

```javascript
Modal.confirm('Header', 'Some content', Severity.error, [
  {
    text: 'Based on trigger()',
    trigger: function () {
      console.log('Vintage!');
    }
  },
  {
    text: 'Based on action',
    action: new DeferredAction(() => {
      return new AjaxRequest('/any/endpoint').post({});
    })
  }
]);

```

Activating any action disables all buttons in the modal. Once the action is
done, the modal disappears automatically.

Buttons of the type `DeferredAction` render a spinner on activation
into the button.
