Claude Skill

ai-elements

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.

LLM Mart · 0 points · 1 views 0 listing impressions 0 install-command copies
Download mxyhi-ok-skills-ai-elements-7933c15.zip · 356 KB

Install

skills CLI npx skills add https://github.com/mxyhi/ok-skills/tree/main/ai-elements
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install mxyhi-ok-skills@llmmart
Git git clone https://github.com/mxyhi/ok-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole mxyhi/ok-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

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 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.

Files (ok-skills)
  • references
    • agent.md 4.1 KB
      Loading…
    • artifact.md 2.9 KB
      Loading…
    • attachments.md 5.6 KB
      Loading…
    • audio-player.md 5.2 KB
      Loading…
    • canvas.md 1.1 KB
      Loading…
    • chain-of-thought.md 3.3 KB
      Loading…
    • checkpoint.md 5.5 KB
      Loading…
    • code-block.md 5.4 KB
      Loading…
    • commit.md 5.8 KB
      Loading…
    • confirmation.md 8.6 KB
      Loading…
    • connection.md 1.1 KB
      Loading…
    • context.md 5.6 KB
      Loading…
    • controls.md 971 B
      Loading…
    • conversation.md 7.4 KB
      Loading…
    • edge.md 2.1 KB
      Loading…
    • environment-variables.md 3.7 KB
      Loading…
    • file-tree.md 2 KB
      Loading…
    • image.md 4 KB
      Loading…
    • inline-citation.md 10.8 KB
      Loading…
    • jsx-preview.md 3.2 KB
      Loading…
    • message.md 9.4 KB
      Loading…
    • mic-selector.md 7.7 KB
      Loading…
    • model-selector.md 4.3 KB
      Loading…
    • node.md 2.8 KB
      Loading…
    • open-in-chat.md 2.7 KB
      Loading…
    • package-info.md 3.2 KB
      Loading…
    • panel.md 1 KB
      Loading…
    • persona.md 5.4 KB
      Loading…
    • plan.md 3.2 KB
      Loading…
    • prompt-input.md 19.8 KB
      Loading…
    • queue.md 5.4 KB
      Loading…
    • reasoning.md 7.8 KB
      Loading…
    • sandbox.md 4.3 KB
      Loading…
    • schema-display.md 2.5 KB
      Loading…
    • shimmer.md 1.6 KB
      Loading…
    • snippet.md 2.2 KB
      Loading…
    • sources.md 6.2 KB
      Loading…
    • speech-input.md 6.5 KB
      Loading…
    • stack-trace.md 7.9 KB
      Loading…
    • suggestion.md 3.6 KB
      Loading…
    • task.md 6.7 KB
      Loading…
    • terminal.md 3.1 KB
      Loading…
    • test-results.md 5 KB
      Loading…
    • tool.md 8.5 KB
      Loading…
    • toolbar.md 983 B
      Loading…
    • transcription.md 4.9 KB
      Loading…
    • voice-selector.md 10.3 KB
      Loading…
    • web-preview.md 6.1 KB
      Loading…
  • scripts
    • agent.tsx 1.6 KB · in bundle
    • artifact.tsx 2.9 KB · in bundle
    • attachments-inline.tsx 3.5 KB · in bundle
    • attachments-list.tsx 2.2 KB · in bundle
    • attachments.tsx 2 KB · in bundle
    • audio-player-remote.tsx 1 KB · in bundle
    • audio-player.tsx 1.8 KB · in bundle
    • chain-of-thought.tsx 138.6 KB · in bundle
    • checkpoint.tsx 2.8 KB · in bundle
    • code-block-dark.tsx 1 KB · in bundle
    • code-block.tsx 2.9 KB · in bundle
    • commit.tsx 2.1 KB · in bundle
    • confirmation-accepted.tsx 1.2 KB · in bundle
    • confirmation-rejected.tsx 1.1 KB · in bundle
    • confirmation-request.tsx 1.7 KB · in bundle
    • confirmation.tsx 1.7 KB · in bundle
    • context.tsx 1005 B · in bundle
    • conversation.tsx 4.1 KB · in bundle
    • environment-variables.tsx 1.7 KB · in bundle
    • file-tree-basic.tsx 380 B · in bundle
    • file-tree-expanded.tsx 609 B · in bundle
    • file-tree-selection.tsx 619 B · in bundle
    • file-tree.tsx 1.5 KB · in bundle
    • image.tsx 136.5 KB · in bundle
    • inline-citation.tsx 3.2 KB · in bundle
    • jsx-preview.tsx 3.2 KB · in bundle
    • message.tsx 10.1 KB · in bundle
    • mic-selector.tsx 1.2 KB · in bundle
    • model-selector.tsx 8.5 KB · in bundle
    • open-in-chat.tsx 704 B · in bundle
    • package-info.tsx 1.3 KB · in bundle
    • persona-command.tsx 2.5 KB · in bundle
    • persona-glint.tsx 2.5 KB · in bundle
    • persona-halo.tsx 2.5 KB · in bundle
    • persona-mana.tsx 2.5 KB · in bundle
    • persona-obsidian.tsx 2.5 KB · in bundle
    • persona-opal.tsx 2.5 KB · in bundle
    • plan.tsx 1.9 KB · in bundle
    • prompt-input-cursor.tsx 15.1 KB · in bundle
    • prompt-input-tooltip.tsx 1.1 KB · in bundle
    • prompt-input.tsx 7.4 KB · in bundle
    • queue-prompt-input.tsx 10.5 KB · in bundle
    • queue.tsx 8 KB · in bundle
    • reasoning.tsx 2.2 KB · in bundle
    • sandbox.tsx 5.4 KB · in bundle
    • schema-display-basic.tsx 221 B · in bundle
    • schema-display-body.tsx 487 B · in bundle
    • schema-display-nested.tsx 470 B · in bundle
    • schema-display-params.tsx 374 B · in bundle
    • schema-display.tsx 2.7 KB · in bundle
    • shimmer-duration.tsx 934 B · in bundle
    • shimmer-elements.tsx 1.1 KB · in bundle
    • shimmer.tsx 443 B · in bundle
    • snippet-plain.tsx 362 B · in bundle
    • snippet.tsx 589 B · in bundle
    • sources-custom.tsx 1 KB · in bundle
    • sources.tsx 752 B · in bundle
    • speech-input.tsx 2.3 KB · in bundle
    • stack-trace-collapsed.tsx 1.1 KB · in bundle
    • stack-trace-no-internal.tsx 1.2 KB · in bundle
    • stack-trace.tsx 1.9 KB · in bundle
    • suggestion-input.tsx 4.4 KB · in bundle
    • suggestion.tsx 802 B · in bundle
    • task.tsx 1.5 KB · in bundle
    • terminal-basic.tsx 169 B · in bundle
    • terminal-clear.tsx 523 B · in bundle
    • terminal-streaming.tsx 1007 B · in bundle
    • terminal.tsx 2.3 KB · in bundle
    • test-results-basic.tsx 464 B · in bundle
    • test-results-errors.tsx 1.3 KB · in bundle
    • test-results-suites.tsx 901 B · in bundle
    • test-results.tsx 2.7 KB · in bundle
    • tool-input-available.tsx 738 B · in bundle
    • tool-input-streaming.tsx 683 B · in bundle
    • tool-output-available.tsx 1.7 KB · in bundle
    • tool-output-error.tsx 1.1 KB · in bundle
    • tool.tsx 6.7 KB · in bundle
    • transcription.tsx 4.9 KB · in bundle
    • voice-selector.tsx 7.1 KB · in bundle
    • web-preview.tsx 2.8 KB · in bundle
  • SKILL.md 7.1 KB
    ---
    name: ai-elements
    description: 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.
    ---
    
    # AI Elements
    
    [AI Elements](https://www.npmjs.com/package/ai-elements) is a component library and custom registry built on top of [shadcn/ui](https://ui.shadcn.com/) 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](https://nodejs.org/en/download/), version 18 or later
    - A [Next.js](https://nextjs.org/) project with the [AI SDK](https://ai-sdk.dev/) installed.
    - [shadcn/ui](https://ui.shadcn.com/) 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](https://vercel.com/docs/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](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys&title=Get%20your%20AI%20Gateway%20key).
    
    ## 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:
    
    ```tsx title="conversation.tsx"
    "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:
    
    ```tsx title="components/ai-elements/message.tsx" highlight="8"
    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:
    
    ```bash title="Terminal"
    npx ai-elements@latest
    ```
    
    If all else fails, feel free to open an [issue on GitHub](https://github.com/vercel/ai-elements/issues).
    
    ### 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.
    
    ```json title="tsconfig.json"
    {
      "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](https://github.com/vercel/ai-elements/issues) and someone will be happy to assist.
    
    ## Available Components
    
    See the `references/` folder for detailed documentation on each component.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.