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.

from dash import Dash, Input, Output, html, dcc, callback

app = Dash(__name__)

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

    dcc.Dropdown(['Safe', 'Danger!!'], id='dropdown-danger'),

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

@callback(Output('output-danger', 'children'),
              Input('confirm-danger', '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.

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.

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.