Preview
Loading GPUI
Props
Variants
One quick doubt
Pass a single confirmation for a lightweight "are you sure?" gate.
Loading GPUI
DoubtButton::new("log-out")
.label("Log out")
.confirmations(["Sure about that?"])
.success_label("Bye.")Maximum dread
A longer chain for the truly irreversible.
Loading GPUI
DoubtButton::new("self-destruct")
.label("Self destruct")
.confirmations([
"Are you sure?",
"Like, really?",
"No takebacks.",
"Think it through.",
"Final answer?",
"Going once...",
"Going twice...",
])
.success_label("Boom.")Install
cargo add evilbuttonsUsage
use evilbuttons::DoubtButton;
DoubtButton::new("wipe")
.label("Delete everything")
.success_label("Too late.")
.on_confirm(|_, _| wipe_database())Props
DoubtButton is a GPUI RenderOnce builder; its state is keyed by id.
| Method | Type | Default | Description |
|---|---|---|---|
new(id) | impl Into<ElementId> | - | Unique id for the button's state. |
label(s) | impl Into<SharedString> | "Delete everything" | Label shown in the idle state. |
confirmations(list) | IntoIterator<Item: Into<SharedString>> | 6 escalating prompts | Prompts shown one per click; the last one fires the action. |
success_label(s) | impl Into<SharedString> | "Too late." | Label flashed after the final confirmation. |
on_confirm(f) | Fn(&mut Window, &mut App) | - | Fired only after the last confirmation is clicked. |
reset_after(d) | Duration | 1600ms | How long to stay in the success state before resetting. Duration::ZERO stays. |
disabled(bool) | bool | false | Dims the button and ignores input. |
Good to know
- Needs
confirmations.len() + 1clicks beforeon_confirm. - An empty
confirmationslist makes it a normal button. - Works from the keyboard too: Space or Enter counts as a click.