← 返回 Skills 市场
anderskev

Ai Elements

作者 Kevin Anderson · GitHub ↗ · v1.1.1 · MIT-0
cross-platform ✓ 安全检测通过
158
总下载
0
收藏
1
当前安装
2
版本数
在 OpenClaw 中安装
/install ai-elements
功能描述
Vercel AI Elements for workflow UI components. Use when building chat interfaces, displaying tool execution, showing reasoning/thinking, or creating job queu...
使用说明 (SKILL.md)

AI Elements

AI Elements is a comprehensive React component library for building AI-powered user interfaces. The library provides 30+ components specifically designed for chat interfaces, tool execution visualization, reasoning displays, and workflow management.

Installation

Install via shadcn registry:

npx shadcn@latest add https://ai-elements.vercel.app/r/[component-name]

Import Pattern: Components are imported from individual files, not a barrel export:

// Correct - import from specific files
import { Conversation } from "@/components/ai-elements/conversation";
import { Message } from "@/components/ai-elements/message";
import { PromptInput } from "@/components/ai-elements/prompt-input";

// Incorrect - no barrel export
import { Conversation, Message } from "@/components/ai-elements";

Gates (before relying on examples)

Use this sequence when adding or wiring AI Elements so setup is checkable, not assumed.

  1. Install each component — Run npx shadcn@latest add https://ai-elements.vercel.app/r/[component-name] for every component you need.

    • Pass: The command completes successfully and a file for that component exists under your project’s components/ai-elements/ (or the directory components.json uses for those additions).
  2. Align import paths — Every import … from "@/components/ai-elements/..." must match your repo’s actual alias and folder layout.

    • Pass: Each import resolves to a file on disk (IDE navigation or build/tsc shows no “cannot find module” for those paths).
  3. Match Tool / Confirmation states to your AI SDK — State strings (including approval-related states) depend on the installed ai package major/version.

    • Pass: The states you pass to ToolHeader, Tool, or Confirmation are listed in the AI SDK version you have installed (docs or exported types), not copied from memory alone.

Component Categories

Conversation Components

Components for displaying chat-style interfaces with messages, attachments, and auto-scrolling behavior.

  • Conversation: Container with auto-scroll capabilities
  • Message: Individual message display with role-based styling
  • MessageAttachment: File and image attachments
  • MessageBranch: Alternative response navigation

See references/conversation.md for details.

Prompt Input Components

Advanced text input with file attachments, drag-and-drop, speech input, and state management.

  • PromptInput: Form container with file handling
  • PromptInputTextarea: Auto-expanding textarea
  • PromptInputSubmit: Status-aware submit button
  • PromptInputAttachments: File attachment display
  • PromptInputProvider: Global state management

See references/prompt-input.md for details.

Workflow Components

Components for displaying job queues, tool execution, and approval workflows.

  • Queue: Job queue container
  • QueueItem: Individual queue items with status
  • Tool: Tool execution display with collapsible states
  • Confirmation: Approval workflow component
  • Reasoning: Collapsible thinking/reasoning display

See references/workflow.md for details.

Visualization Components

ReactFlow-based components for workflow visualization and custom node types.

  • Canvas: ReactFlow wrapper with aviation-specific defaults
  • Node: Custom node component with handles
  • Edge: Temporary and Animated edge types
  • Controls, Panel, Toolbar: Navigation and control elements

See references/visualization.md for details.

Integration with shadcn/ui

AI Elements is built on top of shadcn/ui and integrates seamlessly with its theming system:

  • Uses shadcn/ui's design tokens (colors, spacing, typography)
  • Respects light/dark mode via CSS variables
  • Compatible with shadcn/ui components (Button, Card, Collapsible, etc.)
  • Follows shadcn/ui's component composition patterns

Key Design Patterns

Component Composition

AI Elements follows a composition-first approach where larger components are built from smaller primitives:

\x3CTool>
  \x3CToolHeader title="search" type="tool-call-search" state="output-available" />
  \x3CToolContent>
    \x3CToolInput input={{ query: "AI tools" }} />
    \x3CToolOutput output={results} errorText={undefined} />
  \x3C/ToolContent>
\x3C/Tool>

Context-Based State

Many components use React Context for state management:

  • PromptInputProvider for global input state
  • MessageBranch for alternative response navigation
  • Confirmation for approval workflow state
  • Reasoning for collapsible thinking state

Controlled vs Uncontrolled

Components support both controlled and uncontrolled patterns:

// Uncontrolled (self-managed state)
\x3CPromptInput onSubmit={handleSubmit} />

// Controlled (external state)
\x3CPromptInputProvider initialInput="">
  \x3CPromptInput onSubmit={handleSubmit} />
\x3C/PromptInputProvider>

Tool State Machine

The Tool component follows the Vercel AI SDK's state machine:

  1. input-streaming: Parameters being received
  2. input-available: Ready to execute
  3. approval-requested: Awaiting user approval (SDK v6)
  4. approval-responded: User responded (SDK v6)
  5. output-available: Execution completed
  6. output-error: Execution failed
  7. output-denied: Approval denied

Queue Patterns

Queue components support hierarchical organization:

\x3CQueue>
  \x3CQueueSection defaultOpen={true}>
    \x3CQueueSectionTrigger>
      \x3CQueueSectionLabel count={3} label="tasks" icon={\x3CIcon />} />
    \x3C/QueueSectionTrigger>
    \x3CQueueSectionContent>
      \x3CQueueList>
        \x3CQueueItem>
          \x3CQueueItemIndicator completed={false} />
          \x3CQueueItemContent>Task description\x3C/QueueItemContent>
        \x3C/QueueItem>
      \x3C/QueueList>
    \x3C/QueueSectionContent>
  \x3C/QueueSection>
\x3C/Queue>

Auto-Scroll Behavior

The Conversation component uses the use-stick-to-bottom hook for intelligent auto-scrolling:

  • Automatically scrolls to bottom when new messages arrive
  • Pauses auto-scroll when user scrolls up
  • Provides scroll-to-bottom button when not at bottom
  • Supports smooth and instant scroll modes

File Attachment Handling

PromptInput provides comprehensive file handling:

  • Drag-and-drop support (local or global)
  • Paste image/file support
  • File type validation (accept prop)
  • File size limits (maxFileSize prop)
  • Maximum file count (maxFiles prop)
  • Preview for images, icons for files
  • Automatic blob URL to data URL conversion on submit

Speech Input

The PromptInputSpeechButton uses the Web Speech API for voice input:

  • Browser-based speech recognition
  • Continuous recognition mode
  • Interim results support
  • Automatic text insertion into textarea
  • Visual feedback during recording

Reasoning Auto-Collapse

The Reasoning component provides auto-collapse behavior:

  • Opens automatically when streaming starts
  • Closes 1 second after streaming ends
  • Tracks thinking duration in seconds
  • Displays "Thinking..." with shimmer effect during streaming
  • Shows "Thought for N seconds" when complete

TypeScript Types

All components are fully typed with TypeScript:

import type { ToolUIPart, FileUIPart, UIMessage } from "ai";

type ToolProps = ComponentProps\x3Ctypeof Collapsible>;
type QueueItemProps = ComponentProps\x3C"li">;
type MessageAttachmentProps = HTMLAttributes\x3CHTMLDivElement> & {
  data: FileUIPart;
  onRemove?: () => void;
};

Common Use Cases

Chat Interface

Combine Conversation, Message, and PromptInput for a complete chat UI:

import { Conversation, ConversationContent, ConversationScrollButton } from "@/components/ai-elements/conversation";
import { Message, MessageContent, MessageResponse } from "@/components/ai-elements/message";
import {
  PromptInput,
  PromptInputTextarea,
  PromptInputFooter,
  PromptInputTools,
  PromptInputButton,
  PromptInputSubmit
} from "@/components/ai-elements/prompt-input";

\x3Cdiv className="flex flex-col h-screen">
  \x3CConversation>
    \x3CConversationContent>
      {messages.map(msg => (
        \x3CMessage key={msg.id} from={msg.role}>
          \x3CMessageContent>
            \x3CMessageResponse>{msg.content}\x3C/MessageResponse>
          \x3C/MessageContent>
        \x3C/Message>
      ))}
    \x3C/ConversationContent>
    \x3CConversationScrollButton />
  \x3C/Conversation>

  \x3CPromptInput onSubmit={handleSubmit}>
    \x3CPromptInputTextarea />
    \x3CPromptInputFooter>
      \x3CPromptInputTools>
        \x3CPromptInputButton onClick={() => attachments.openFileDialog()}>
          \x3CPaperclipIcon />
        \x3C/PromptInputButton>
      \x3C/PromptInputTools>
      \x3CPromptInputSubmit status={chatStatus} />
    \x3C/PromptInputFooter>
  \x3C/PromptInput>
\x3C/div>

Tool Execution Display

Show tool execution with expandable details:

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

{toolInvocations.map(tool => (
  \x3CTool key={tool.id}>
    \x3CToolHeader
      title={tool.toolName}
      type={`tool-call-${tool.toolName}`}
      state={tool.state}
    />
    \x3CToolContent>
      \x3CToolInput input={tool.args} />
      {tool.result && (
        \x3CToolOutput output={tool.result} errorText={tool.error} />
      )}
    \x3C/ToolContent>
  \x3C/Tool>
))}

Approval Workflow

Request user confirmation before executing actions:

import {
  Confirmation,
  ConfirmationTitle,
  ConfirmationRequest,
  ConfirmationActions,
  ConfirmationAction,
  ConfirmationAccepted,
  ConfirmationRejected
} from "@/components/ai-elements/confirmation";

\x3CConfirmation approval={tool.approval} state={tool.state}>
  \x3CConfirmationTitle>
    Approve deletion of {resource}?
  \x3C/ConfirmationTitle>

  \x3CConfirmationRequest>
    \x3CConfirmationActions>
      \x3CConfirmationAction onClick={approve} variant="default">
        Approve
      \x3C/ConfirmationAction>
      \x3CConfirmationAction onClick={reject} variant="outline">
        Reject
      \x3C/ConfirmationAction>
    \x3C/ConfirmationActions>
  \x3C/ConfirmationRequest>

  \x3CConfirmationAccepted>
    Action approved and executed.
  \x3C/ConfirmationAccepted>

  \x3CConfirmationRejected>
    Action rejected.
  \x3C/ConfirmationRejected>
\x3C/Confirmation>

Job Queue Management

Display task lists with completion status:

import {
  Queue,
  QueueSection,
  QueueSectionTrigger,
  QueueSectionLabel,
  QueueSectionContent,
  QueueList,
  QueueItem,
  QueueItemIndicator,
  QueueItemContent,
  QueueItemDescription
} from "@/components/ai-elements/queue";

\x3CQueue>
  \x3CQueueSection>
    \x3CQueueSectionTrigger>
      \x3CQueueSectionLabel count={todos.length} label="todos" />
    \x3C/QueueSectionTrigger>
    \x3CQueueSectionContent>
      \x3CQueueList>
        {todos.map(todo => (
          \x3CQueueItem key={todo.id}>
            \x3CQueueItemIndicator completed={todo.status === 'completed'} />
            \x3CQueueItemContent completed={todo.status === 'completed'}>
              {todo.title}
            \x3C/QueueItemContent>
            {todo.description && (
              \x3CQueueItemDescription completed={todo.status === 'completed'}>
                {todo.description}
              \x3C/QueueItemDescription>
            )}
          \x3C/QueueItem>
        ))}
      \x3C/QueueList>
    \x3C/QueueSectionContent>
  \x3C/QueueSection>
\x3C/Queue>

Accessibility

Components include accessibility features:

  • ARIA labels and roles
  • Keyboard navigation support
  • Screen reader announcements
  • Focus management
  • Semantic HTML elements

Animation

Many components use Framer Motion for smooth animations:

  • Shimmer effect for loading states
  • Collapsible content transitions
  • Edge animations in Canvas
  • Loader spinner rotation

References

安全使用建议
This skill is documentation for a UI component library and appears coherent with that purpose. However, the SKILL.md recommends using npx to fetch components from https://ai-elements.vercel.app — before running that command: (1) verify the domain and the package contents (prefer inspecting the repository or a GitHub release when possible), (2) run the install in a safe/dev environment first, (3) confirm compatibility with your installed shadcn and ai SDK major versions (state strings differ by SDK version), and (4) review the downloaded component files for unexpected scripts or postinstall steps. Because the registry entry ships only docs, there was nothing for a static scanner to inspect — treat remote installs as the primary risk and review them manually.
能力评估
Purpose & Capability
Name, description, and the included reference docs consistently describe a UI component library for chat/workflow/visualization. There are no unrelated environment variables, binaries, or config paths requested.
Instruction Scope
Runtime instructions are documentation-style: how to install components via shadcn, import patterns, and usage examples. The instructions do not ask the agent to read unrelated files, access credentials, or transmit data externally beyond the noted install URL. They do require verifying SDK state strings against the installed ai SDK version (reasonable for this domain).
Install Mechanism
The skill itself has no registry install spec and no code shipped in the registry, but SKILL.md tells users to run `npx shadcn@latest add https://ai-elements.vercel.app/r/[component-name]`, which will fetch remote files from ai-elements.vercel.app. Fetching code from a third-party URL is potentially risky if the URL isn't vetted. The pattern is consistent with shadcn-style component registries but you should confirm the source before running.
Credentials
No environment variables, credentials, or config paths are requested — the documentation does not attempt to access secrets or unrelated system state.
Persistence & Privilege
`always` is false and the skill is user-invocable; there is no indication the skill requests permanent presence or modifies other skills or system-wide agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install ai-elements
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /ai-elements 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.1
- Added a new "Gates" section to clarify setup steps before using AI Elements, including per-component installation, import path verification, and state matching requirements. - No changes to library API or components; this update improves documentation accuracy and reliability for initial integration. - Other documentation content remains unchanged.
v1.1.0
**Expanded component library, enhanced documentation, and improved workflow patterns for building AI interfaces.** - Introduced a comprehensive SKILL.md covering 30+ components for chat, workflow, and visualization interfaces. - Detailed installation, import patterns, and integration with shadcn/ui. - Documented new component categories: Conversation, PromptInput, Workflow, and Visualization. - Added examples for component usage, composition patterns, and state management (context, controlled/uncontrolled). - Described Queue, Tool state machine, auto-scroll, file attachment, speech input, and reasoning components’ behaviors with usage details.
元数据
Slug ai-elements
版本 1.1.1
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 2
常见问题

Ai Elements 是什么?

Vercel AI Elements for workflow UI components. Use when building chat interfaces, displaying tool execution, showing reasoning/thinking, or creating job queu... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 158 次。

如何安装 Ai Elements?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install ai-elements」即可一键安装,无需额外配置。

Ai Elements 是免费的吗?

是的,Ai Elements 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Ai Elements 支持哪些平台?

Ai Elements 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Ai Elements?

由 Kevin Anderson(@anderskev)开发并维护,当前版本 v1.1.1。

💬 留言讨论