本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)12k · #11506

ai-elements

できること

AIが、shadcn/uiをもとにしたAIチャットのコンポーネントを、Next.jsプロジェクトに追加する手順を案内します。チャットボットやAIアシスタントの画面を作る開発者向けです。

使う場面

  • ✓Next.jsアプリでチャットボットやAIアシスタントの画面を作りたいとき。
  • ✓チャットのメッセージ、ツールの出力、プロンプト入力に既成のコンポーネントが必要なとき。
  • ✓既にshadcn/uiを使っているプロジェクトにAI Elementsを加えたいとき。

スキルのリンク

https://github.com/trycompai/crm/blob/release/.agents/skills/ai-elements/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/trycompai/crm/blob/release/.agents/skills/ai-elements/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“メッセージの吹き出しとプロンプトの入力欄がある、チャット画面をNext.jsアプリに追加する手伝いをしてもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIはプロジェクトに合ったパッケージ実行ツールでコンポーネントを導入し、プロジェクトに追加して、チャットの画面に接続します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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.

IMPORTANT: Run all CLI commands using the project's package runner: npx ai-elements@latest, pnpm dlx ai-elements@latest, or bunx --bun ai-elements@latest — based on the project's packageManager. Examples below use npx ai-elements@latest but substitute the correct runner for the project.

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 yo

よくある質問

最初に必要なものは何ですか?

Node.js 18以降、AI SDKを使うNext.jsプロジェクト、shadcn/uiが必要です。

どのパッケージ実行ツールを使いますか?

npx、pnpm dlx、bunxなど、プロジェクトに合ったものを使います。

AIゲートウェイを勧めていますか?

はい。AI Gatewayの利用を勧め、そのAPIキーをローカルの環境変数ファイルに追加するよう案内します。

詳細

作者による元の説明

Build AI chat interfaces using ai-elements components — conversations, messages, tool displays, prompt inputs, and more. Use when the user wants to build a chatbot, AI assistant UI, or any AI-powered chat interface.

repo: trycompai/crm

人気

GitHubのスター
12k
ランキング
#11506
ライセンス
MIT
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル