Shadcn Prompt Input Components

A chat composer for AI apps with an autogrowing textarea, file and image attachments, model and effort pickers, action menus, tool toggles, slash commands and a submit button that switches to stop while a reply streams. Built on AI Elements and shadcn/ui. Browse our collection of 10 Shadcn Prompt Input variants.

Basic

Enter to send, Shift + Enter for a new line

Submit status

Ready

Image attachments

Up to 3 images, 5 MB each.

Model and effort pickers

Action menu

Tool toggles

Character limit

88 / 280

With suggestions

Empty chat

Slash commands

/ for commands
Writing assistant

Chat composer

How can I help today?

Ask a question or attach a file to get started.

AI assistant
Unlock premium components
Get full control of shadcn/ui components, blocks and instances, including future additions.

Explore Shadcn Blocks

Ready-made page sections built with the same components.

View all blocks

Shadcn Prompt Input Component

The Shadcn Prompt Input is the message composer of an AI chat: an autogrowing textarea with a toolbar underneath for attachments, model pickers and tools, and a submit button that turns into a stop button while the answer streams. It is the part of a chatbot, copilot or agent interface that users touch the most.

The examples here cover a basic composer, the full submit status cycle, image attachments with type, count and size limits, model and effort selects, a plus action menu, tool toggles, a character counter, suggestion chips, slash commands and a complete chat window. They use the Prompt Input from AI Elements, which is built on shadcn/ui Input Group, Select, Dropdown Menu and Command components, with React and Tailwind CSS. Responses in the demos are simulated with timers, so you can plug in the AI SDK or any other backend.

What is the Shadcn Prompt Input Component?

A prompt input is a form that wraps an Input Group. The textarea grows with its content, Enter submits the form and Shift + Enter adds a new line. Files can be added from a hidden file input, by pasting into the textarea or by dropping them on the form, and they are passed to onSubmit together with the text.

Use it wherever users write instructions for a model: chat apps, in app assistants, image generators and code agents. For a plain form field without submit behavior, a Textarea is enough, and for picking from a list of actions a Command menu fits better.

Anatomy of the Shadcn Prompt Input

PartDescription
PromptInputThe form root. Takes onSubmit, which receives { text, files }, plus accept, multiple, maxFiles, maxFileSize, globalDrop and onError for attachments.
PromptInputBody and PromptInputTextareaThe body holds the textarea. The textarea grows up to max-h-48, submits on Enter, ignores Enter while an IME is composing, adds pasted files and removes the last attachment on Backspace when it is empty.
PromptInputHeaderA row above the textarea for attachment chips, a selected command or context badges.
PromptInputFooter and PromptInputToolsThe bottom bar. Tools groups buttons and selects on the left, the submit button usually sits on the right.
PromptInputButtonA ghost toolbar button with an optional tooltip, which can be a string or an object with content, shortcut and side.
PromptInputSubmitThe send button. Its status prop shows a spinner for submitted, a stop icon for streaming and an X for error; with onStop it becomes a stop button while generating.
PromptInputActionMenuA Dropdown Menu with a plus trigger, content aligned to the start and menu items for actions like adding files.
PromptInputSelectA borderless Select for model, effort or style pickers inside the footer.
PromptInputCommandCommand list parts for slash commands or mention menus rendered inside the composer.
PromptInputProvider and hooksusePromptInputAttachments reads and changes the files from inside the form. PromptInputProvider lifts text and files out of the form so useProviderAttachments and usePromptInputController work anywhere in the tree.

10 Shadcn Prompt Input Variants

Each prompt input variant listed here is previewed live at the top of this page, together with its source code and install command.

  • Basic: A textarea with a round send button that stays disabled while the field is empty, plus a keyboard hint.
  • Submit status: Cycles from ready to submitted to streaming and back, with a stop button that cancels the simulated reply.
  • Image attachments: Accepts images only, up to three files of 5 MB each, shows thumbnails with remove buttons and explains rejected files.
  • Model and effort pickers: An attach button and two selects for the model and the reasoning effort in the footer.
  • Action menu and tool toggles: A plus menu that adds files and turns tools on as removable chips, and pressed state toggles for Search, Deep research and Think.
  • Character limit: A live counter that turns red, marks the field invalid and disables submit once the prompt is too long.
  • Suggestions and slash commands: Suggestion chips that fill the textarea, and a slash command menu with arrow key navigation that becomes a removable chip.
  • Chat composer: A complete chat window where sent messages and attachments appear above the input and the reply streams word by word.

How to Install the Shadcn Prompt Input Component

Set up shadcn/ui in your project if you have not already, then add the Shadcn UI Kit registry to your components.json once:

{
  "registries": {
    "@shadcnuikit": "https://shadcnuikit.com/r/{name}.json"
  }
}

Then install a prompt input variant by its name:

npx shadcn@latest add @shadcnuikit/prompt-input1

The same command works with pnpm dlx, yarn dlx and bunx --bun. Each variant has a copy button for every package manager, and the code is added to your project as plain React and Tailwind CSS that you can edit freely.

How to Use the Shadcn Prompt Input Component

Put the textarea inside PromptInputBody and the actions in PromptInputFooter. Control the text with value and onChange when you need to clear it or disable the submit button, and read the message in onSubmit.

"use client"

import { useState } from "react"
import { ArrowUpIcon } from "lucide-react"

import {
  PromptInput,
  PromptInputBody,
  PromptInputFooter,
  PromptInputSubmit,
  PromptInputTextarea,
  type PromptInputMessage,
} from "@/components/ui/prompt-input"

export function Composer() {
  const [text, setText] = useState("")

  const handleSubmit = (message: PromptInputMessage) => {
    if (!message.text.trim()) return
    sendMessage(message.text, message.files)
    setText("")
  }

  return (
    <PromptInput onSubmit={handleSubmit}>
      <PromptInputBody>
        <PromptInputTextarea
          value={text}
          onChange={(event) => setText(event.currentTarget.value)}
          placeholder="Ask anything..."
        />
      </PromptInputBody>
      <PromptInputFooter className="justify-end">
        <PromptInputSubmit disabled={!text.trim()} className="rounded-full">
          <ArrowUpIcon />
        </PromptInputSubmit>
      </PromptInputFooter>
    </PromptInput>
  )
}

Why Use the Shadcn Prompt Input Component

  • Chat keyboard behavior built in: Enter to send, Shift + Enter for a new line and safe handling of IME composition work without extra code.
  • Attachments out of the box: File dialog, paste, drag and drop, type filters, file count and size limits, with error codes you can turn into messages.
  • Streaming aware submit: One status prop switches the button between send, spinner, stop and error states.
  • Composable toolbar: Buttons, selects, menus and command lists are separate parts, so each product can build its own footer.
  • Uses your theme: Every part is a shadcn/ui component styled with Tailwind classes and your theme variables.

Common Prompt Input Use Cases

  • Chatbots and assistants: The main input of a chat app or an in product helper.
  • Writing tools: Slash commands for summarize, rewrite and translate.
  • Image and media generation: Prompts with reference images, aspect ratio and style pickers.
  • Code agents: Instructions with files, model choice and tool toggles.
  • Search and research: Web search and deep research modes next to the input.

Customizing the Shadcn Prompt Input

The form renders an Input Group, so style it from the form with a child selector such as *:data-[slot=input-group]:rounded-xl. Padding for the textarea, header and footer goes on each part through className. Colors and radius come from your theme variables, and the free Theme Generator can create a matching palette.

To limit attachments and show a friendly message, map the error codes from onError:

const messages = {
  accept: "Only images can be attached.",
  max_files: "You can attach up to 3 images.",
  max_file_size: "Each image must be 5 MB or smaller.",
}

<PromptInput
  accept="image/*"
  multiple
  maxFiles={3}
  maxFileSize={5 * 1024 * 1024}
  onError={(error) => setError(messages[error.code])}
  onSubmit={handleSubmit}
>
  ...
</PromptInput>

Prompt Input Accessibility and Keyboard Support

The composer is a native form, so the submit button and Enter key work like any other form. Icon only buttons such as attach, stop and send need an aria-label; the submit button already switches its label between Submit and Stop while generating.

Give toggles a pressed state so screen readers announce whether a tool is on, and set aria-invalid on the textarea when the prompt breaks a rule like a character limit. Selects, menus and command lists use the keyboard support of their Radix and cmdk primitives.

KeyAction
EnterSubmits the prompt unless the submit button is disabled.
ShiftEnterInserts a new line in the textarea.
BackspaceRemoves the last attachment when the textarea is empty.
TabMoves focus between the textarea, toolbar buttons and submit.
EscapeCloses an open menu or select and returns focus to its trigger.

Prompt Input Best Practices

  • Disable the submit button while the prompt is empty so Enter does not send blank messages.
  • Show a stop button during streaming and let users cancel long answers.
  • Restrict attachments with accept, maxFiles and maxFileSize, and explain every rejected file.
  • Keep the footer short on mobile: hide labels behind icons and move rare actions into the plus menu.
  • Offer suggestions in empty chats so new users know what to ask.

Shadcn Prompt Input for AI Agents

Prompt Input gives an agent every piece of a chat composer: a form whose onSubmit receives text and files, a textarea that sends on Enter, attachments with accept, maxFiles and maxFileSize limits, footer selects for model and effort, a plus action menu, slash command lists and a submit button driven by a status prop. It can wire the status to useChat from the AI SDK so the button shows a spinner, then a stop button, while the answer streams.

Install it with an AI agent

Claude Code, Cursor, Codex and other agents can install these with the shadcn CLI, for example npx shadcn@latest add @shadcnuikit/prompt-input1. With the Shadcn UI Kit MCP server, your agent can search every variant by name and add the right one for you. To give it full context, share /components/prompt-input.md, the Markdown version of this page with every variant and install command.

Example prompts

  • “Connect the Chat composer example to our /api/chat route with useChat, passing status and stop to PromptInputSubmit and the attached files with each message.”
  • “Add a model select and a reasoning effort select to our assistant composer, stored in user settings and sent with every request.”
  • “Build slash commands for /summarize, /rewrite and /translate in the editor sidebar composer, with arrow key navigation and a removable chip for the chosen command.”

Customize it with AI

Ask the agent to style the composer from the form with selectors like *:data-[slot=input-group]:rounded-xl instead of editing components/ui/prompt-input.tsx. Never pass tooltip to PromptInputActionMenuTrigger, because the tooltip wrapper breaks the dropdown trigger; add menu items that call openFileDialog from usePromptInputAttachments instead. Map onError codes to readable messages, and wrap the tree in PromptInputProvider when attachments or text must be shown outside the form.

Components Related to Prompt Input

Shadcn Prompt Input FAQ

PromptInputTextarea does this by default. Enter calls requestSubmit on the form unless the submit button is disabled, and Shift + Enter keeps the default new line. Enter is ignored while an IME is composing text.

Pass status and onStop to PromptInputSubmit. With status submitted or streaming and an onStop handler, the button becomes a type button labelled Stop and calls onStop instead of submitting.

Set accept="image/*" on PromptInput and add maxFiles and maxFileSize if needed. Files that break a rule are skipped. onError receives accept or max_file_size when no file passes the check, and max_files when some files did not fit.

onSubmit receives a message with text and files. Each file has a filename, mediaType and url, and blob URLs are converted to data URLs before onSubmit is called.

Yes. Wrap it in PromptInputProvider, then use usePromptInputController to read or set the text and useProviderAttachments to add or remove files from any component in the tree.

Yes. Claude Code, Cursor, Copilot and other assistants can add a prompt input variant with the shadcn CLI or the shadcn MCP server, for example npx shadcn@latest add @shadcnuikit/prompt-input1. With a Pro plan, the Shadcn UI Kit MCP server can also build complete sections and pages around it.

Open /components/prompt-input.md to get this page as Markdown, with every prompt input variant, its description and install command. Paste the link or the text into your AI tool so it uses the real component code instead of guessing.

Looking for something else? Browse all shadcn/ui components or ready-made UI blocks built with them.