Confirm popover
A destructive button that grows into a small card: the consequence, an optional type-to-confirm phrase that fills Delete as you type, progress on the button, then a check in the button's shape or the error with Try again.
oxyn add confirm-popoverlet mut p = use_signal(ConfirmPopover::new);
p.write().confirm_text = Some("acme-web".into()); // type to confirm
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}Rendered from Rust at build time · goes live when visible
When to use
- A destructive button that grows into a small confirmation card: the consequence in one or two sentences, an optional type-to-confirm phrase (case and outer spaces ignored) that fills Confirm as the typed prefix matches, progress on the Confirm button (reported or an indeterminate sweep), then a check in the button's shape, or the failure with the rejection message and Try again.
When not to use
- An agent asks before it acts: use Approval Card instead.
- Several open requests in one card: use Approval pager instead.
- An agent's question in its own card above the composer: use Decision Card instead.
Installation
Confirm popover is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add confirm-popoveruse crate::oxyn::{ConfirmPopover, STATUS_INDICATOR_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{ConfirmPopover, STATUS_INDICATOR_CSS};
Usage
let mut p = use_signal(ConfirmPopover::new);
p.write().confirm_text = Some("acme-web".into()); // type to confirm
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}Examples
Phrase
Type the project name to unlock Delete.
Code
let mut p = use_signal(ConfirmPopover::new);
p.write().confirm_text = Some("acme-web".into()); // type to confirm
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}Plain
Consequence and two buttons.
Code
let mut p = use_signal(ConfirmPopover::new);
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}Neutral
Reversible: foreground fill.
Code
let mut p = use_signal(ConfirmPopover::new);
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}Error
Fails: the message and Try again.
Code
let mut p = use_signal(ConfirmPopover::new);
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}Sweep
No progress reported: an indeterminate sweep.
Code
let mut p = use_signal(ConfirmPopover::new);
rsx! {
ConfirmPopover {
model: p(),
now: clock.now(),
description: "This removes the acme-web project…",
on_submit: move |_| if p.write().submit(now) { spawn(delete(p)) },
on_type: move |s| p.write().type_text(&s),
}
}API reference
ConfirmPopover
| Prop | Type | Default | Description |
|---|---|---|---|
modelrequired | PopModel | — | Model. |
nowrequired | ClockMs | — | Shared clock. |
label | String | "Delete project" | Trigger label. |
title | String | "Delete this project?" | Card heading. |
description | Option<String> | Default::default() | The consequence (describes the dialog). |
icon | String | "trash" | Trigger icon. |
confirm_label | String | "Delete" | Confirm label. |
cancel_label | String | "Cancel" | Cancel label. |
pending_label | String | "Deleting" | Progress label. |
success_label | String | "Deleted" | Success label (no longer than the trigger label). |
error_title | String | "That didn't work" | Failure heading. |
retry_label | String | "Try again" | Retry label. |
on_show | EventHandler<()> | — | Trigger pressed. |
on_dismiss | EventHandler<()> | — | Cancel or Escape. |
on_type | EventHandler<String> | — | Phrase typed. |
on_submit | EventHandler<()> | — | Confirm pressed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| Enter | Confirm (shakes when the phrase does not match) |
| Escape | Dismiss |
| Tab | Phrase field, Cancel, Delete |
Accessibility
- The card is an alertdialog named by its heading and described by the consequence.
- The trigger has aria-expanded; Delete is aria-disabled until the phrase matches (case and outer spaces ignored).
From the spec
- Trigger: aria-expanded + aria-haspopup=dialog.
- Card: role=alertdialog named by its heading, described by the consequence.
- Delete is aria-disabled until unlocked; the phrase field gets aria-invalid when it stops matching.
Motion & interaction
Timing
- Card grows from the kept edge (scale .94 → 1, 200 ms).
- Wrong submit: 320 ms damped shake (6 px).
- Reduced motion: no grow, no shake (the field is marked invalid instead).
Responsive behaviour
- 300 px card, max 100 %; `end` keeps the right edge for buttons at the end of a row.
Edge cases (spec)
- 300 px card, max 100 %; align start / center / end.
Notes for AI
- Import
ConfirmPopoverfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
ConfirmPopoverElinoxyn_gpui. - Props to set first:
model,now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.