Confirmation
An agent asks before a risky step, then shows what was decided.
Delete 3 stale views?
Installation
pnpm add @heyramzi/uiUsage
import {
Confirmation,
ConfirmationTitle,
ConfirmationState,
ConfirmationActions,
ConfirmationAction,
type ConfirmationKind,
} from "@heyramzi/ui/ai/confirmation";<Confirmation {kind}>
<ConfirmationTitle>Delete 3 stale views?</ConfirmationTitle>
<ConfirmationState when="requested">
<ConfirmationActions>
<ConfirmationAction variant="outline" onclick={() => (kind = "rejected")}>Cancel</ConfirmationAction>
<ConfirmationAction onclick={() => (kind = "accepted")}>Delete</ConfirmationAction>
</ConfirmationActions>
</ConfirmationState>
<ConfirmationState when="accepted">Deleted 3 views.</ConfirmationState>
<ConfirmationState when="rejected">Kept the views.</ConfirmationState>
</Confirmation>Keyboard and accessibility
| Key | Does |
|---|---|
| Tab | Moves focus between the action buttons. |
| Space Enter | Runs the focused action. |
- The box is a region named "Confirmation". It reports busy while the action runs.
- It's a polite live region from the moment it shows, so the result is read out.
- While the action runs the buttons report disabled and focus stays put. Once it resolves the buttons go away and focus moves to the box.
- With reduced motion on, the state swap doesn't animate.
API reference
Confirmation.Confirmation
kindrequired"idle" | "requested" | "accepted" | "rejected" | "failed"executingboolean- Default
false classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
kind required | "idle" | "requested" | "accepted" | "rejected" | "failed" | |
executing | boolean | false |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLElement> from svelte/elements | |
Confirmation.Title
classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLParagraphElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLParagraphElement> from svelte/elements | |
Confirmation.State
whenrequiredExclude<ConfirmationKind, "idle">- The state whose content this shows.
childrenSnippet
| Prop | Type | Default |
|---|---|---|
when required The state whose content this shows. | Exclude<ConfirmationKind, "idle"> | |
children | Snippet |
Confirmation.Actions
classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Confirmation.Action
busyLabelstringbusyWhen"always" | "default" | "never"- Default
"default" variant"default" | "outline" | "ghost" | "destructive" | "text" | "dashed"- Default
"default" size"sm" | "default" | "lg"- Default
"sm" iconbooleanrefHTMLButtonElement | HTMLAnchorElement | nullclassstringdisabledbooleanchildrenSnippet...rest- Every prop of
HTMLButtonAttributesfromsvelte/elements ...rest- Every prop of
HTMLAnchorAttributesfromsvelte/elements
| Prop | Type | Default |
|---|---|---|
busyLabel | string | |
busyWhen | "always" | "default" | "never" | "default" |
variant | "default" | "outline" | "ghost" | "destructive" | "text" | "dashed" | "default" |
size | "sm" | "default" | "lg" | "sm" |
icon | boolean | |
ref | HTMLButtonElement | HTMLAnchorElement | null | |
class | string | |
disabled | boolean | |
children | Snippet | |
...rest | Every prop of HTMLButtonAttributes from svelte/elements | |
...rest | Every prop of HTMLAnchorAttributes from svelte/elements | |