ConfirmationDialog
A dialog used to confirm a user action.
@solara.component
def ConfirmationDialog(
open: Union[solara.Reactive[bool], bool],
*,
on_close: Union[None, Callable[[], None]] = None,
content: Union[str, solara.Element] = "",
title: str = "Confirm action",
ok: Union[str, solara.Element] = "OK",
on_ok: Callable[[], None] = lambda: None,
cancel: Union[str, solara.Element] = "Cancel",
on_cancel: Callable[[], None] = lambda: None,
children: List[solara.Element] = [],
max_width: Union[int, str] = 500,
persistent: bool = False,
):
...
(Note: This component is experimental and its API may change in the future.)
By default, has a title, a text explaining the decision to be made, and two buttons "OK" and "Cancel".
Basic examples
import solara
open_delete_confirmation = solara.reactive(False)
def delete_user():
# put your code to perform the action here
print("User being deleted...")
@solara.component
def Page():
solara.Button(label="Delete user", on_click=lambda: open_delete_confirmation.set(True))
solara.lab.ConfirmationDialog(open_delete_confirmation, ok="Ok, Delete", on_ok=delete_user, content="Are you sure you want to delete this user?")
Live output
Arguments
open
: Indicates whether the dialog is being shown or not.on_open
: Callback to call when the dialog opens of closes.content
: Message that is displayed.title
: Title of the dialog.ok
: If a string, this text will be displayed on the confirmation button (default is "OK"). If a Button, it will be used instead of the default button.on_ok
: Callback to be called when the OK button is clicked.cancel
: If a string, this text will be displayed on the cancellation button (default is "Cancel"). If a Button, it will be used instead of the default button.on_cancel
: Callback to be called when the Cancel button is clicked. When persistent is False, clicking outside of the element or pressing esc key will also trigger cancel.children
: Additional components that will be shown under the dialog message, but before the buttons.max_width
: Maximum width of the dialog window.persistent
: When False (the default), clicking outside of the element or pressing esc key will trigger cancel.
Example
Users:
Alice
Bob
Cindy
Dirk
Eve
Fred