> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/extending-overview/extension-types/modals/confirm-dialog.md).

# Confirm Dialog

Confirmation dialogs are used to ask the user for confirmation to complete some action and are presented as a center-aligned modal in the backoffice.

Extension authors do not need to register the dialog in their extension's manifest, instead these dialogs are opened by importing and calling the `umbOpenModal` function.

Extension authors can customize the dialog with configuration options such as headline, body content, colors, and button labels.

* `headline` - The headline of the modal.
* `content` - The content of the modal, which can be a TemplateResult or a string.
* `color` - (Optional) The color of the modal, can be `positive` or `danger`. Defaults to `positive`.
* `confirmLabel` - (Optional) The label of the confirmation button.
* `cancelLabel` - (Optional) The label of the cancel button.

To see all properties of the `UMB_CONFIRM_MODAL` token, see the [API reference](https://apidocs.umbraco.com/v17/ui-api/interfaces/packages_core_modal.UmbConfirmModalData.html).

The `onSubmit` method returns a promise that resolves when the user confirms the dialog, and rejects when the user cancels the dialog.

## Opening a Confirmation Dialog

{% code title="my-element.ts" %}

```typescript
import {
    html,
    LitElement,
    customElement,
} from "@umbraco-cms/backoffice/external/lit";
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
import { umbOpenModal, UMB_CONFIRM_MODAL } from "@umbraco-cms/backoffice/modal";

@customElement("my-confirmation-modal")
export class MyConfirmationModal extends UmbElementMixin(LitElement) {
    #onRequestDisable() {
        umbOpenModal(this, UMB_CONFIRM_MODAL, {
            data: {
                headline: this.localize.term("actions_disable"),
                content: this.localize.term("defaultdialogs_confirmdisable"),
                color: "danger",
                confirmLabel: this.localize.term("actions_disable"),
            },
        })
            .then(() => {
                console.log("User has approved");
            })
            .catch(() => {
                console.log("User has rejected");
            });
    }

    render() {
        return html`<uui-button
            look="primary"
            color="danger"
            @click=${this.#onRequestDisable}
            label=${this.localize.term("actions_disable")}
        ></uui-button>`;
    }
}
```

{% endcode %}

## Convenience Method

Confirmation dialogs can be opened using the `umbConfirmModal` method, which offers a slightly simplified API.

{% code title="my-element.ts" %}

```typescript
import {
    html,
    LitElement,
    customElement,
} from "@umbraco-cms/backoffice/external/lit";
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
import { umbConfirmModal } from "@umbraco-cms/backoffice/modal";

@customElement("restart-services-modal")
export class RestartServicesModal extends UmbElementMixin(LitElement) {
    #onRequestDisable() {
        umbConfirmModal(this, {
            headline: this.localize.term("actions_disable"),
            content: this.localize.term("defaultdialogs_confirmdisable"),
            color: "danger",
            confirmLabel: this.localize.term("actions_disable"),
        })
            .then(() => {
                console.log("User has approved");
            })
            .catch(() => {
                console.log("User has rejected");
            });
    }

    render() {
        return html`<uui-button
            look="primary"
            color="positive"
            @click=${this.#onRequestDisable}
            label=${this.localize.term("actions_disable")}
        ></uui-button>`;
    }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/extending-overview/extension-types/modals/confirm-dialog.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
