Skip to content

Actions

ConfirmButton

tsx
"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

tsx
"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.

tsx
"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

onConfirm() => voidrequired

Runs when the second step is confirmed.

onCancel() => void

Runs when the confirm step closes without confirming.

iconReactNode

Trigger icon. Defaults to a trash can.

aria-labelstring

Accessible name of the trigger. Defaults to "Delete".

confirmLabelstring

Name of the confirm button. Defaults to "Confirm".

cancelLabelstring

Name of the cancel button. Defaults to "Cancel".

resetAfternumber

Milliseconds before the confirm step closes by itself; 0 keeps it open. Defaults to 4000.

size"md" | "lg"

Control size. Defaults to "md".

wrapperClassNamestring

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.