Tool Input Available Example

PreviousNext

Example implementation of tool input-available.

Docs
ai-elementsblock

Preview

Loading preview…
registry/default/examples/tool-input-available.tsx
"use client";

import { Tool, ToolContent, ToolHeader, ToolInput } from "@/components/ai-elements/tool";
import { nanoid } from "nanoid";

const toolCall = {
  type: "tool-image_generation" as const,
  toolCallId: nanoid(),
  state: "input-available" as const,
  input: {
    prompt: "A futuristic cityscape at sunset with flying cars",
    style: "digital_art",
    resolution: "1024x1024",
    quality: "high",
  },
  output: undefined,
  errorText: undefined,
};

const Example = () => (
  <div style={{ height: "500px" }}>
    <Tool>
      <ToolHeader state={toolCall.state} type={toolCall.type} />
      <ToolContent>
        <ToolInput input={toolCall.input} />
      </ToolContent>
    </Tool>
  </div>
);

export default Example;

Installation

npx shadcn@latest add @ai-elements/example-tool-input-available

Usage

import { ExampleToolInputAvailable } from "@/components/example-tool-input-available"
<ExampleToolInputAvailable />