dcc.ConfirmDialog is used to display the browser’s native
“confirm” modal, with an optional message and two buttons (“OK” and “Cancel”).
This ConfirmDialog can be used in conjunction with buttons when the user is
performing an action that should require an extra step of verification.

See dcc.ConfirmDialogProvider
for an easier way to display an alert when clicking on an item.

import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
        message='Danger danger! Are you sure you want to continue?',

            {'label': i, 'value': i}
            for i in ['Safe', 'Danger!!']

@app.callback(Output('confirm', 'displayed'),
              Input('dropdown', 'value'))
def display_confirm(value):
    if value == 'Danger!!':
        return True
    return False

@app.callback(Output('output-confirm', 'children'),
              Input('confirm', 'submit_n_clicks'))
def update_output(submit_n_clicks):
    if submit_n_clicks:
        return 'It wasnt easy but we did it {}'.format(submit_n_clicks)

if __name__ == '__main__':

ConfirmDialog Properties

Access this documentation in your Python terminal with:


Our recommended IDE for writing Dash apps is Dash Enterprise’s
Data Science Workspaces,
which has typeahead support for Dash Component Properties.
Find out if your company is using
Dash Enterprise

id (string; optional):
The ID of this component, used to identify dash components in
callbacks. The ID needs to be unique across all of the components
in an app.

cancel_n_clicks (number; default 0):
Number of times the popup was canceled.

cancel_n_clicks_timestamp (number; default -1):
Last time the cancel button was clicked.

displayed (boolean; optional):
Set to True to send the ConfirmDialog.

message (string; optional):
Message to show in the popup.

submit_n_clicks (number; default 0):
Number of times the submit button was clicked.

submit_n_clicks_timestamp (number; default -1):
Last time the submit button was clicked.