jpskill.com
🛠️ 開発・MCP コミュニティ

ai-elements

Create new AI chat interface components for the ai-elements library following established composable patterns, shadcn/ui integration, and Vercel AI SDK conventions. Use when creating new components in packages/elements/src or when the user asks to add a new component to ai-elements.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ai-elements.zip https://jpskill.com/download/21006.zip && unzip -o ai-elements.zip && rm ai-elements.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/21006.zip -OutFile "$d\ai-elements.zip"; Expand-Archive "$d\ai-elements.zip" -DestinationPath $d -Force; ri "$d\ai-elements.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して ai-elements.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → ai-elements フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
129

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

AI Elements

AI Elements は、AI ネイティブアプリケーションをより迅速に構築できるように、shadcn/ui の上に構築されたコンポーネントライブラリおよびカスタムレジストリです。会話やメッセージなどの事前構築済みコンポーネントを提供しています。

AI Elements のインストールは簡単で、いくつかの方法で行うことができます。最速のセットアップには専用の CLI コマンドを使用できますし、すでに shadcn のワークフローを採用している場合は、標準の shadcn/ui CLI を介して統合することも可能です。

クイックスタート

AI Elements のコンポーネントを使用して達成できることの基本的な例をいくつかご紹介します。

前提条件

AI Elements をインストールする前に、お使いの環境が以下の要件を満たしていることを確認してください。

  • Node.js バージョン 18 以降
  • AI SDK がインストールされた Next.js プロジェクト
  • プロジェクトに shadcn/ui がインストールされていること。インストールされていない場合でも、いずれかのインストールコマンドを実行すると自動的にインストールされます。
  • また、AI Gateway の使用を強くお勧めします。AI_GATEWAY_API_KEYenv.local に追加することで、すべてのプロバイダーから API キーを使用する必要がなくなります。AI Gateway は毎月 5 ドルの使用量も提供するため、モデルを試すことができます。API キーはこちらで取得できます。

コンポーネントのインストール

AI Elements コンポーネントは、AI Elements CLI または shadcn/ui CLI のいずれかを使用してインストールできます。どちらも同じ結果、つまり選択したコンポーネントのコードと必要な依存関係をプロジェクトに追加します。

CLI はコンポーネントのコードをダウンロードし、プロジェクトのディレクトリ(通常は components フォルダー内)に統合します。デフォルトでは、AI Elements コンポーネントは @/components/ai-elements/ ディレクトリ(または shadcn コンポーネント設定で構成したフォルダー)に追加されます。

コマンドの実行後、ファイルが追加されたことを示す確認メッセージがターミナルに表示されます。その後、コードでコンポーネントを使用できます。

使用方法

AI Elements コンポーネントがインストールされると、他の React コンポーネントと同様に、アプリケーションでインポートして使用できます。コンポーネントはコードベースの一部として(ライブラリに隠されることなく)追加されるため、非常に自然な使用感です。

AI Elements コンポーネントをインストールすると、他の React コンポーネントと同様にアプリケーションで使用できます。例:

"use client";

import {
  Message,
  MessageContent,
  MessageResponse,
} from "@/components/ai-elements/message";
import { useChat } from "@ai-sdk/react";

const Example = () => {
  const { messages } = useChat();

  return (
    <>
      {messages.map(({ role, parts }, index) => (
        <Message from={role} key={index}>
          <MessageContent>
            {parts.map((part, i) => {
              switch (part.type) {
                case "text":
                  return (
                    <MessageResponse key={`${role}-${i}`}>
                      {part.text}
                    </MessageResponse>
                  );
              }
            })}
          </MessageContent>
        </Message>
      ))}
    </>
  );
};

export default Example;

上記の例では、AI Elements ディレクトリから Message コンポーネントをインポートし、JSX に含めています。次に、MessageContent および MessageResponse サブコンポーネントでコンポーネントを構成しています。コンポーネントのコードはプロジェクト内に存在するため、自分で書いた場合と同様にスタイル設定や構成を行うことができます。コンポーネントファイルを開いて動作を確認したり、カスタム変更を加えたりすることも可能です。

拡張性

すべての AI Elements コンポーネントは、可能な限り多くのプリミティブ属性を受け入れます。たとえば、Message コンポーネントは HTMLAttributes<HTMLDivElement> を拡張しているため、div がサポートする任意の props を渡すことができます。これにより、独自のスタイルや機能でコンポーネントを簡単に拡張できます。

カスタマイズ

インストール後、追加のセットアップは不要です。コンポーネントのスタイル(Tailwind CSS クラス)とスクリプトはすでに統合されています。すぐにアプリでコンポーネントとの対話を開始できます。

たとえば、Message の角丸を削除したい場合は、components/ai-elements/message.tsx に移動して、次のように rounded-lg を削除できます。

export const MessageContent = ({
  children,
  className,
  ...props
}: MessageContentProps) => (
  <div
    className={cn(
      "flex flex-col gap-2 text-sm text-foreground",
      "group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground group-[.is-user]:px-4 group-[.is-user]:py-3",
      className
    )}
    {...props}
  >
    <div className="is-user:dark">{children}</div>
  </div>
);

トラブルシューティング

コンポーネントにスタイルが適用されないのはなぜですか?

プロジェクトが Tailwind 4 の shadcn/ui 用に正しく構成されていることを確認してください。これは、Tailwind をインポートし、shadcn/ui のベーススタイルを含む globals.css ファイルがあることを意味します。

AI Elements CLI を実行しましたが、プロジェクトに何も追加されませんでした

以下を再確認してください。

  • 現在の作業ディレクトリがプロジェクトのルート(package.json がある場所)であること。
  • components.json ファイル(shadcn スタイルの設定を使用している場合)が正しく設定されていること。
  • AI Elements CLI の最新バージョンを使用していること:
npx ai-elements@latest

すべてがうまくいかない場合は、お気軽に GitHub で issue を開いてください

テーマ切り替えが機能しません — アプリがライトモードのままです

アプリが shadcn/ui および AI Elements が期待するのと同じ data-theme システムを使用していることを確認してください。デフォルトの実装では、<html> 要素の data-theme 属性を切り替えます。tailwind.config.js がそれに応じて class または data- セレクターを使用していることを確認してください。

コンポーネントのインポートが「module not found」で失敗します

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

AI Elements

AI Elements is a component library and custom registry built on top of shadcn/ui to help you build AI-native applications faster. It provides pre-built components like conversations, messages and more.

Installing AI Elements is straightforward and can be done in a couple of ways. You can use the dedicated CLI command for the fastest setup, or integrate via the standard shadcn/ui CLI if you've already adopted shadcn's workflow.

Quick Start

Here are some basic examples of what you can achieve using components from AI Elements.

Prerequisites

Before installing AI Elements, make sure your environment meets the following requirements:

  • Node.js, version 18 or later
  • A Next.js project with the AI SDK installed.
  • shadcn/ui installed in your project. If you don't have it installed, running any install command will automatically install it for you.
  • We also highly recommend using the AI Gateway and adding AI_GATEWAY_API_KEY to your env.local so you don't have to use an API key from every provider. AI Gateway also gives $5 in usage per month so you can experiment with models. You can obtain an API key here.

Installing Components

You can install AI Elements components using either the AI Elements CLI or the shadcn/ui CLI. Both achieve the same result: adding the selected component’s code and any needed dependencies to your project.

The CLI will download the component’s code and integrate it into your project’s directory (usually under your components folder). By default, AI Elements components are added to the @/components/ai-elements/ directory (or whatever folder you’ve configured in your shadcn components settings).

After running the command, you should see a confirmation in your terminal that the files were added. You can then proceed to use the component in your code.

Usage

Once an AI Elements component is installed, you can import it and use it in your application like any other React component. The components are added as part of your codebase (not hidden in a library), so the usage feels very natural.

Example

After installing AI Elements components, you can use them in your application like any other React component. For example:

"use client";

import {
  Message,
  MessageContent,
  MessageResponse,
} from "@/components/ai-elements/message";
import { useChat } from "@ai-sdk/react";

const Example = () => {
  const { messages } = useChat();

  return (
    <>
      {messages.map(({ role, parts }, index) => (
        <Message from={role} key={index}>
          <MessageContent>
            {parts.map((part, i) => {
              switch (part.type) {
                case "text":
                  return (
                    <MessageResponse key={`${role}-${i}`}>
                      {part.text}
                    </MessageResponse>
                  );
              }
            })}
          </MessageContent>
        </Message>
      ))}
    </>
  );
};

export default Example;

In the example above, we import the Message component from our AI Elements directory and include it in our JSX. Then, we compose the component with the MessageContent and MessageResponse subcomponents. You can style or configure the component just as you would if you wrote it yourself – since the code lives in your project, you can even open the component file to see how it works or make custom modifications.

Extensibility

All AI Elements components take as many primitive attributes as possible. For example, the Message component extends HTMLAttributes<HTMLDivElement>, so you can pass any props that a div supports. This makes it easy to extend the component with your own styles or functionality.

Customization

After installation, no additional setup is needed. The component’s styles (Tailwind CSS classes) and scripts are already integrated. You can start interacting with the component in your app immediately.

For example, if you'd like to remove the rounding on Message, you can go to components/ai-elements/message.tsx and remove rounded-lg as follows:

export const MessageContent = ({
  children,
  className,
  ...props
}: MessageContentProps) => (
  <div
    className={cn(
      "flex flex-col gap-2 text-sm text-foreground",
      "group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground group-[.is-user]:px-4 group-[.is-user]:py-3",
      className
    )}
    {...props}
  >
    <div className="is-user:dark">{children}</div>
  </div>
);

Troubleshooting

Why are my components not styled?

Make sure your project is configured correctly for shadcn/ui in Tailwind 4 - this means having a globals.css file that imports Tailwind and includes the shadcn/ui base styles.

I ran the AI Elements CLI but nothing was added to my project

Double-check that:

  • Your current working directory is the root of your project (where package.json lives).
  • Your components.json file (if using shadcn-style config) is set up correctly.
  • You’re using the latest version of the AI Elements CLI:
npx ai-elements@latest

If all else fails, feel free to open an issue on GitHub.

Theme switching doesn’t work — my app stays in light mode

Ensure your app is using the same data-theme system that shadcn/ui and AI Elements expect. The default implementation toggles a data-theme attribute on the <html> element. Make sure your tailwind.config.js is using class or data- selectors accordingly:

The component imports fail with “module not found”

Check the file exists. If it does, make sure your tsconfig.json has a proper paths alias for @/ i.e.

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./*"]
    }
  }
}

My AI coding assistant can't access AI Elements components

  1. Verify your config file syntax is valid JSON.
  2. Check that the file path is correct for your AI tool.
  3. Restart your coding assistant after making changes.
  4. Ensure you have a stable internet connection.

Still stuck?

If none of these answers help, open an issue on GitHub and someone will be happy to assist.

Available Components

See the references/ folder for detailed documentation on each component.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。