Confirmation

An alert-based component for managing tool execution approval workflows with request, accept, and reject states.

Installation

pnpm dlx shadcn-svelte@latest add https://svelte-ai-elements.vercel.app/r/confirmation.json

If you prefer using jsrepo, please install via the command below:

pnpm dlx jsrepo add @ai/elements/ai-elements/confirmation

Usage

Examples

Approval Request State

Approved State

Rejected State

With AI SDK

Features

  • State-based rendering for different approval stages
  • Built on shadcn-svelte Alert component for consistent styling
  • Flexible action buttons with customizable variants
  • Context-based component composition
  • TypeScript support with proper type definitions
  • Accessible with proper ARIA attributes
  • Seamless integration with Vercel AI SDK
  • Responsive design with mobile support

Component API

Confirmation

PropTypeDefaultDescription
approvalToolUIPartApproval-Approval object containing id, approved status, and optional reason
stateToolUIPartState-Current state: 'approval-requested' | 'approval-responded' | 'output-denied' | 'output-available'
classstring-Additional CSS classes to apply to the alert container
childrenSnippet-Child components (ConfirmationTitle, ConfirmationRequest, etc.)
...restPropsHTMLAttributes<HTMLDivElement>-All other div props are supported

ConfirmationTitle

PropTypeDefaultDescription
classstring-Additional CSS classes to apply to the title
childrenSnippet-Title content

ConfirmationRequest

PropTypeDefaultDescription
childrenSnippet-Content to show when approval is requested (typically ConfirmationActions)

ConfirmationAccepted

PropTypeDefaultDescription
childrenSnippet-Content to show when action is approved

ConfirmationRejected

PropTypeDefaultDescription
childrenSnippet-Content to show when action is rejected

ConfirmationActions

PropTypeDefaultDescription
classstring-Additional CSS classes to apply to the actions container
childrenSnippet-Action buttons (ConfirmationAction components)

ConfirmationAction

PropTypeDefaultDescription
variant'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link''default'Button variant style
size'default' | 'sm' | 'lg' | 'icon''sm'Button size
classstring-Additional CSS classes to apply to the button
childrenSnippet-Button content
onclick(e: MouseEvent) => void-Click handler function
...restPropsHTMLButtonAttributes-All other button props are supported