Rounded AI prompt box with attach tools, a round send button and a shimmering "Searching the web" status below.
Set your access key from API keys as NEXTUI_TOKEN in .env.local and add the @nextui namespace below to components.json once. Then every item installs by name. Each install counts as a copy on a free account.
$pnpm dlx shadcn@latest add @nextui/chat-input
1{2"registries": {3"@nextui": {4"url": "https://nextui.dev/r/{name}.json",5"headers": { "Authorization": "Bearer ${NEXTUI_TOKEN}" }6}7}8}
1"use client";23import { useState } from "react";4import { Paperclip } from "lucide-react";5import { AiChatInput } from "@/components/nextui/chat-input";67export function Composer({ onSend }: { onSend: (message: string) => Promise<void> }) {8const [busy, setBusy] = useState(false);910return (11<AiChatInput12placeholder="Ask anything about your docs…"13tools={[{ label: "Attach file", icon: Paperclip, onClick: () => console.log("attach") }]}14sources={[{ label: "Web" }, { label: "Docs" }, { label: "News" }]}15status={busy ? "Thinking…" : null}16onSubmit={async (message) => {17setBusy(true);18await onSend(message);19setBusy(false);20}}21/>22);23}
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | – | Controlled message text |
| defaultValue | string | "" | Starting text when uncontrolled |
| onChange | (value: string) => void | – | Called with the new text on each keystroke |
| onSubmit | (message: string) => void | – | Enter or the send button; the box clears when uncontrolled |
| placeholder | string | "Ask Tini AI Assistant…" | Placeholder text |
| rows | number | 3 | Visible rows of the textarea |
| tools | ChatTool[] | Add, Attach file, Add image, Search files | Icon buttons in the toolbar: label, icon and onClick |
| sources | ChatSource[] | Five pastel gradient avatars | Avatars in the status row: label, optional icon, and colour classes (omit for a pastel gradient) |
| status | ReactNode | "Searching the web…" | Shimmering status text; null hides the row |
| className | string | – | Extra classes on the wrapper |
Sign in to see the code
Preview it freely. A free account copies code and prompts a few times a day.