Send an alert with dcc.ConfirmDialog
when the user clicks the children of this component, usually a button.
from dash import Dash, Input, Output, html, dcc, callback
app = Dash()
app.layout = html.Div([
dcc.ConfirmDialogProvider(
children=html.Button('Click Me',),
id='danger-danger-provider',
message='Danger danger! Are you sure you want to continue?'
),
html.Div(id='output-provider')
])
@callback(Output('output-provider', 'children'),
Input('danger-danger-provider', 'submit_n_clicks'))
def update_output(submit_n_clicks):
if not submit_n_clicks:
return ''
return """
It was dangerous but we did it!
Submitted {} times
""".format(submit_n_clicks)
if __name__ == '__main__':
app.run(debug=True)
Access this documentation in your Python terminal with:
```pythonhelp(dash.dcc.ConfirmDialogProvider)
```
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.
children
(boolean | number | string | list | dict; optional):
The children to hijack clicks from and display the popup.
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 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):
Is the modal currently displayed.
loading_state
(dict; optional):
Object that holds the loading state object coming from dash-renderer.
loading_state
is a dict with keys:
component_name
(string; optional):
Holds the name of the component that is loading.
is_loading
(boolean; optional):
Determines if the component is loading or not.
prop_name
(string; optional):
Holds which property is loading.