AI Primitives

Getting started

Installation

Add components to your React and Tailwind CSS v4 project with the shadcn CLI. The code is copied into your project, so you own it.

1. Set up shadcn

npx shadcn@latest init

2. Add the AI Primitives registry

npx shadcn@latest registry add @ai-primitive=https://ai-primitive.vercel.app/r/{name}.json

3. Add the theme and components

npx shadcn@latest add @ai-primitive/theme @ai-primitive/chat-bubble @ai-primitive/prompt-input

All components

  • Button - Core button with six variants and sizes down to icon-only.
  • Copy Button - Icon button that copies text to the clipboard and confirms with a checkmark.
  • Code Block - Syntax-highlighted code block with a language label and a built-in copy button.
  • Dialog - A modal for focused tasks and confirmations - centered on larger screens, a bottom sheet on phones.
  • Dropdown Menu - Menus with actions, radio and checkbox items, shortcuts and destructive states.
  • Tooltip - Labels for icon-only controls, with shared delays so a row of buttons reads quickly.
  • Switch - An on/off toggle for settings that take effect immediately.
  • Tabs - Switch between related views with a segmented tab list.
  • Segmented Control - A compact single-choice control for modes and filters - it can never be left empty.
  • Skeleton - Quiet placeholders in the shape of the content that's loading.
  • Chat Bubble - Message bubble primitives - avatars, filled/no-background appearances, timestamps, and actions.
  • Prompt Input - Auto-resizing chat input with attachments, an action menu, and a compact pill mode.
  • Loader - Twelve loading-indicator styles - spinners, dots, bars, and shimmer text.
  • Text Shimmer - A shimmering gradient sweep across text, for a "thinking" state.
  • Thinking Bar - A shimmering status row with an optional expand action and a stop button.
  • Feedback Bar - A thumbs up / thumbs down row for rating an AI response.
  • System Message - Action, warning, and error banners with an optional icon and call-to-action.
  • Prompt Suggestion - Suggested-prompt pills, or a highlighted-match list for autocomplete.
  • Chat Container - Auto-scrolling chat viewport that sticks to the bottom as messages stream in.
  • Reasoning - A collapsible "thinking" block that auto-opens while streaming and closes when done.
  • Chain of Thought - A vertical trail of collapsible reasoning steps, connected by a line.
  • Steps - A collapsible, numbered list of completed steps with a side rail.
  • Tool - A collapsible tool-call card showing its state, input, output, or error.
  • Source - An inline citation chip that opens a hover card with the linked page's details.
  • Markdown - Streaming-safe markdown renderer with GFM support and code blocks built in.
  • Response Stream - Animates text in token-by-token (typewriter) or word-by-word (fade).
  • JSX Preview - Renders a JSX string as live output, auto-closing open tags mid-stream.
  • Image - Displays a URL, base64, or raw-bytes image, with an animated placeholder while pending.
  • File Upload - A drag-and-drop dropzone that overlays the whole page while a file is dragged over it.