Viora LogoViora UI
Login

Confirm Morph

An inline question button that morphs in-place for destructive or confirmation flows with undo and countdown timeout.

confirm-morph.tsx
Loading source code...

Installation

pnpm dlx viora-ui@latest add confirm-morph
npx viora-ui@latest add confirm-morph
yarn viora-ui@latest add confirm-morph
bunx --bun viora-ui@latest add confirm-morph

Usage

import { Trash2 } from "lucide-react";
import { ConfirmMorph } from "@/components/arc/confirm-morph/confirm-morph";

export function DeleteSelection({ ids = ["file-1", "file-2", "file-3"] }: { ids?: string[] }) {
  const deleteFiles = async (fileIds: string[]) => {
    await new Promise((r) => setTimeout(r, 1200));
    console.log("Deleted files", fileIds);
  };

  const restoreFiles = async (fileIds: string[]) => {
    await new Promise((r) => setTimeout(r, 800));
    console.log("Restored files", fileIds);
  };

  return (
    <ConfirmMorph
      label="Delete"
      icon={<Trash2 size={16} strokeWidth={1.75} />}
      prompt={`Delete ${ids.length} files?`}
      onConfirm={() => deleteFiles(ids)}
      onUndo={() => restoreFiles(ids)}
    />
  );
}

API Reference

ConfirmMorph

PropTypeDefaultDescription
labelReactNode—The resting label content.
promptReactNode—Inline question shown when confirming.
confirmLabelstring"Delete"Action confirm button text.
cancelLabelstring"Cancel"Action cancel button text.
onConfirm() => void | Promise<unknown>—Handler called when confirmed.
onUndo() => void | Promise<unknown>—Handler called when undone.

Built by Otis

Last updated: 10/12/2026