Confirmation
shadcn/uiApproval request prompt displaying pending, approved, and rejected tool execution states.
Confirmation
Clear build cache.next/cacheApproval required
Removes compiled cache entries from .next/cache before running a clean production build.
import { RotateCcw } from "lucide-react";import { useState } from "react";import { Confirmation, ConfirmationAccepted, ConfirmationAction, ConfirmationActions, ConfirmationRejected, ConfirmationRequest, ConfirmationTitle, type ConfirmationState,} from "@/components/optics/ai-elements/confirmation";import { Button } from "@/components/optics/button";function ConfirmationDemo() { const [state, setState] = useState<ConfirmationState>("approval-requested"); const approval = { id: "approval-clean-cache", approved: state === "approved" ? true : state === "rejected" ? false : undefined, }; return ( <div className="flex w-full max-w-lg flex-col gap-4"> <Confirmation state={state} approval={approval}> <ConfirmationTitle description=".next/cache">Clear build cache</ConfirmationTitle> <ConfirmationRequest> <p className="pl-6 text-xs leading-relaxed text-muted-foreground"> Removes compiled cache entries from <code className="font-mono text-foreground">.next/cache</code>{" "} before running a clean production build. </p> </ConfirmationRequest> <ConfirmationAccepted> <p className="pl-6 text-xs leading-relaxed text-muted-foreground"> Tool execution approved. Clearing cached build artifacts and starting compilation. </p> </ConfirmationAccepted> <ConfirmationRejected> <p className="pl-6 text-xs leading-relaxed text-destructive"> Tool execution denied. Existing build cache files were left untouched. </p> </ConfirmationRejected> <ConfirmationActions> <ConfirmationAction intent="deny" onClick={() => setState("rejected")}> Deny </ConfirmationAction> <ConfirmationAction intent="approve" onClick={() => setState("approved")}> Approve </ConfirmationAction> </ConfirmationActions> </Confirmation> <div className="flex items-center justify-end"> <Button type="button" variant="outline" size="sm" disabled={state === "approval-requested"} onClick={() => setState("approval-requested")} > <RotateCcw /> Reset </Button> </div> </div> );}<ConfirmationDemo />import { RotateCcw } from "lucide-react";import { useState } from "react";import { Confirmation, ConfirmationAccepted, ConfirmationAction, ConfirmationActions, ConfirmationRejected, ConfirmationRequest, ConfirmationTitle, type ConfirmationState,} from "@/components/optics/ai-elements/confirmation";import { Button } from "@/components/optics/button";function ConfirmationDemo() { const [state, setState] = useState<ConfirmationState>("approval-requested"); const approval = { id: "approval-clean-cache", approved: state === "approved" ? true : state === "rejected" ? false : undefined, }; return ( <div className="flex w-full max-w-lg flex-col gap-4"> <Confirmation state={state} approval={approval}> <ConfirmationTitle description=".next/cache">Clear build cache</ConfirmationTitle> <ConfirmationRequest> <p className="pl-6 text-xs leading-relaxed text-muted-foreground"> Removes compiled cache entries from <code className="font-mono text-foreground">.next/cache</code>{" "} before running a clean production build. </p> </ConfirmationRequest> <ConfirmationAccepted> <p className="pl-6 text-xs leading-relaxed text-muted-foreground"> Tool execution approved. Clearing cached build artifacts and starting compilation. </p> </ConfirmationAccepted> <ConfirmationRejected> <p className="pl-6 text-xs leading-relaxed text-destructive"> Tool execution denied. Existing build cache files were left untouched. </p> </ConfirmationRejected> <ConfirmationActions> <ConfirmationAction intent="deny" onClick={() => setState("rejected")}> Deny </ConfirmationAction> <ConfirmationAction intent="approve" onClick={() => setState("approved")}> Approve </ConfirmationAction> </ConfirmationActions> </Confirmation> <div className="flex items-center justify-end"> <Button type="button" variant="outline" size="sm" disabled={state === "approval-requested"} onClick={() => setState("approval-requested")} > <RotateCcw /> Reset </Button> </div> </div> );}<ConfirmationDemo />Installation
pnpm dlx shadcn@latest add @optics/ai-confirmation
Props
<Confirmation />
Name | Type | |
|---|---|---|
state | import("/vercel/path0/registry/optics/ai-elements/confirm... | |
approval | import("/vercel/path0/registry/optics/ai-elements/confirm... |
<ConfirmationTitle />
Name | Type | |
|---|---|---|
icon | React.ReactNode | |
description | React.ReactNode | |
badge | React.ReactNode |
<ConfirmationAction />
Name | Type | |
|---|---|---|
variant | "link" | "outline" | "default" | |
intent | "approve" | "deny" | |
render | React.ReactElement | |
nativeButton | boolean | |
focusableWhenDisabled | boolean | |
animation | "none" | "all" | "colors" | "only-scale" |