AI Input
Chat-style AI composer with agent and model chips and an Apple Intelligence-style gradient wave on send.
AI Input
Chat-style AI composer with agent and model chips and an Apple Intelligence-style gradient wave on send.
Installation
Install the component with the Craft-UI Blocks CLI — it drops ai-input.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add ai-inputpnpm dlx mvpblocks add ai-inputyarn dlx mvpblocks add ai-inputbunx mvpblocks add ai-inputFile Structure
The CLI saves the component to your project's components/ui folder:
Import it from @/components/ui/ai-input.
Usage
"use client";
import { useState } from "react";
import { Archive, Camera, LayoutGrid, Paperclip, Plug } from "lucide-react";
import {
AIInput,
AIInputMenuItem,
PromptSettingGroup,
} from "@/components/ui/ai-input";
const settingGroups: PromptSettingGroup[] = [
{
id: "model",
label: "Model",
display: "featured",
options: [
{
value: "claude-5",
label: "Claude 5",
description: "Most capable model",
},
{
value: "claude-5-fast",
label: "Claude 5 Fast",
description: "Faster responses",
},
],
},
{
id: "effort",
label: "Effort",
display: "submenu",
options: [
{ value: "high", label: "High" },
{ value: "medium", label: "Medium" },
{ value: "low", label: "Low" },
],
},
];
const menuItems: AIInputMenuItem[] = [
{ value: "add-files", label: "Add files", icon: Paperclip, shortcut: "⌘U" },
{ value: "screenshot", label: "Screenshot", icon: Camera },
{
value: "add-to-project",
label: "Add to project",
icon: Archive,
items: [
{ value: "homepage", label: "Homepage" },
{ value: "checkout", label: "Checkout" },
{ value: "integration", label: "Integration" },
],
},
{ value: "separator-1", type: "separator" },
{
value: "skills",
label: "Skills",
icon: LayoutGrid,
items: [
{ value: "design", label: "Design" },
{ value: "programming", label: "Programming" },
{ value: "research", label: "Research" },
],
},
{ value: "add-connector", label: "Add connector", icon: Plug },
];
export function AIInputPreview() {
const [messages, setMessages] = useState(["Can you help me get a pass?"]);
return (
<AIInput
defaultAgent="designer"
agents={[{ value: "designer", label: "Designer" }]}
settingGroups={settingGroups}
menuItems={menuItems}
showMessages={messages.length > 0}
placeholder="Ask for follow-up changes"
onSend={(message, meta) => {
setMessages((previous) => [...previous, message]);
void meta;
}}
onMenuSelect={(value) => void value}
onSettingsChange={(settings) => void settings}
/>
);
}Wire the callbacks to your app state: onSend(message, meta) fires on submit with the current agent and settings, onMenuSelect fires when a plus-menu action is picked, and onSettingsChange fires whenever a setting (model, effort, etc.) changes.
Props
Prop
Type
Registry Bundle
Install the exact registry entry when you want ai-input.tsx and its declared runtime dependencies together — motion, lucide-react, and @base-ui/react/input (plus the internal b-switch component, pulled in automatically).
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on