ConfirmButton
"use client";
import { ConfirmButton } from "@cherry-design-system/react";
export function DeleteFile({ id, remove }: { id: string; remove: (id: string) => void }) {
return <ConfirmButton aria-label="Delete report.pdf" onConfirm={() => remove(id)} />;
}A two-step button for destructive actions. The first click widens the control and reveals a Confirm and Cancel pair inside it (the default trash icon lifts its lid). It closes again on Cancel, Escape, or after resetAfter milliseconds. Use a Modal when the action needs more explanation than a confirm step.
Examples
Custom labels and icon
"use client";
import { ConfirmButton } from "@cherry-design-system/react";
import { Archive } from "lucide-react";
export function ArchiveProject({ onArchive }: { onArchive: () => void }) {
return (
<ConfirmButton
aria-label="Archive project"
icon={<Archive />}
confirmLabel="Archive"
cancelLabel="Keep"
onConfirm={onArchive}
/>
);
}Timeout and cancel callback
resetAfter defaults to 4000 ms. Pass 0 to keep the confirm step open until the user acts.
"use client";
import { ConfirmButton } from "@cherry-design-system/react";
export function RemoveMember({ onRemove }: { onRemove: () => void }) {
return (
<ConfirmButton
aria-label="Remove member"
size="lg"
resetAfter={0}
onConfirm={onRemove}
onCancel={() => console.log("kept")}
/>
);
}Properties
Runs when the second step is confirmed.
Runs when the confirm step closes without confirming.
Trigger icon. Defaults to a trash can.
Accessible name of the trigger. Defaults to "Delete".
Name of the confirm button. Defaults to "Confirm".
Name of the cancel button. Defaults to "Cancel".
Milliseconds before the confirm step closes by itself; 0 keeps it open. Defaults to 4000.
Control size. Defaults to "md".
Class for the outer wrapper (className goes to the trigger).
The ref and all native <button> attributes go to the trigger button.
Styling
Root class cherry-confirm-button with data-size (md, lg) and data-state (idle, confirm). The two action buttons carry data-action (confirm, cancel). Parts: cherry-confirm-button__trigger, __glyph, __lid, __clip, __panel, __action.
The confirm action reads --cherry-danger-bg and --cherry-danger-fg; the trigger uses --cherry-secondary-* and --cherry-ring.
Accessibility
The trigger has aria-expanded. Opening moves focus to Confirm; Cancel, Escape, leaving the control or resetAfter closes it and returns focus to the trigger. Give it a specific aria-label such as "Delete report.pdf" rather than the generic default.