Send an alert with DCC.Confirmdialog.confirmdialog
when the user clicks the children of this component, usually a button.
open Dash.NET.Suave
open Dash.NET.DCC
open Dash.NET
open System
let layout =
Html.div [ Attr.children [ ConfirmDialogProvider.confirmDialogProvider
"danger-danger-provider"
[ ConfirmDialogProvider.Attr.message
"Danger danger! Are you sure you want to continue?"
ConfirmDialogProvider.Attr.children [ Html.button [ Attr.children "Click Me" ] ] ]
Html.div [ Attr.id "output-provider" ] ] ]
let callback =
Callback.singleOut (
"danger-danger-provider"
@. CustomProperty "submit_n_clicks",
"output-provider" @. Children,
(fun (nClick: int) ->
let dangerousLabel =
$"It was dangerous but we did it!
Submitted {nClick} times"
let label =
match nClick with
| v when v > 0 -> dangerousLabel
| v -> ""
"output-provider" @. Children => label
))
[<EntryPoint>]
let main args =
DashApp.initDefault()
|> DashApp.withLayout layout
|> DashApp.addCallback callback
|> DashApp.run args
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
(bool | number | string | list | record; 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
(bool; optional):
Is the modal currently displayed.
loading_state
(record; optional):
Object that holds the loading state object coming from dash-renderer.
loading_state
is a record with keys:
component_name
(string; optional):
Holds the name of the component that is loading.
is_loading
(bool; optional):
Determines if the component is loading or not.
prop_name
(string; optional):
Holds which property is loading.