Confirm Button
confirm-buttonA destructive button that grows into its own confirmation on a spring, so the question appears where you are looking. Focus lands on Cancel, Esc or clicking away disarms it, and the confirm button shows a spinner while the action runs.
"use client";
import { Archive, Trash2 } from "lucide-react";
import { useState } from "react";
import { ConfirmButton } from "@/components/forme/confirm-button/confirm-button";
export function ConfirmButtonDemo() {
const [log, setLog] = useState("Nothing deleted yet.");
return (
<div className="flex flex-col items-start gap-4">
<ConfirmButton
icon={<Trash2 aria-hidden />}
question="Delete forme-web?"
onConfirm={() =>
new Promise<void>((resolve) =>
setTimeout(() => {
setLog("forme-web was deleted.");
resolve();
}, 900),
)
}
>
Delete project
</ConfirmButton>
<ConfirmButton
icon={<Archive aria-hidden />}
question="Archive 12 issues?"
confirmLabel="Archive"
onConfirm={() => setLog("12 issues archived.")}
>
Archive closed
</ConfirmButton>
<p aria-live="polite" className="text-caption-1-regular text-muted-foreground">
{log}
</p>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import { ConfirmButton } from "@/components/forme/confirm-button/confirm-button";
<ConfirmButton question="Delete forme-web?" onConfirm={() => deleteProject(id)}>
Delete
</ConfirmButton>When to use
Reach for it
- Everyday destructive actions — removing a row, revoking a token — where a dialog would cost a context switch.
- Rows and toolbars, where the question should appear exactly where the click was.
Use something else
- Anything irreversible at scale, like deleting an account: use a dialog that asks the person to type the name.
- Actions that are safe to undo. Do them at once and offer Undo in a toast instead of asking first.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
ConfirmButton
A destructive action that asks once, in place.
| Prop | Type | Default | Description |
|---|---|---|---|
children* | ReactNode | — | The action, e.g. "Delete project". |
onConfirm* | () => void | Promise<void> | — | |
question | ReactNode | "Are you sure?" | The question shown once armed, e.g. "Delete forme-web?" |
confirmLabel | ReactNode | — | The confirming button's label. Defaults to the action's own label. |
icon | ReactNode | — | |
disabled | boolean | — | |
className | string | — |
Accessibility
- Focus moves to Cancel when it arms, so a second Enter never confirms by accident.
- Escape, or moving focus out of the group, disarms it without running anything.
- While
onConfirmruns the confirm button isaria-busyand keeps its width, so focus and layout stay put.
Motion
- The button grows into the question in 150ms and shrinks back the same way; reduced motion makes both a cut.
Related


Dynamic Island
A black pill that morphs on a spring to fit whatever it is showing: a timer, a call, a song or a notification. Content swaps through a short blur crossfade, the corners never stretch mid-morph, and each change is announced politely.
motion

Marquee
A seamless, endlessly scrolling row for logos, photos or testimonials. It pauses on hover and focus, screen readers hear the content once, and reduced motion turns it into a row you scroll by hand. Pure CSS.
motion

Metal Button
A button with a chrome rim whose reflections travel slowly round it, and a glint that crosses the face on hover. Plain CSS in a server component, still for reduced motion.
motion