ai input search.md
AI Input Search
AI composer with a Tools menu (browse, investigate, draft, run code, reason), a model picker and a live trace that stacks each source's avatar as it is read.
Installation
npx shadcn@latest add @kokonutui/ai-input-search
Props
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder? |
string |
"Ask anything, or type / for tools" |
|
tools? |
SearchTool[] |
built-in |
|
defaultTool? |
string | null |
"browse" |
Tool picked at first. Pass null to start with none. |
models? |
string[] |
built-in |
|
defaultModel? |
string |
"Sonnet 5.5" |
|
onSearch? |
(query: string, options: { tool: SearchTool | null; model: string; files: File[]; signal: AbortSignal; onSource: (source: SearchSource) => void }) => Promise<void> | void |
Runs the request. Call onSource for each source as it is read, and resolve when the answer is ready; signal aborts on Stop. Without it, the component plays a pretend run so the demo feels alive. |
|
className? |
string |
Extra classes for the root element. |
SearchTool
| Field | Type | Description |
|---|---|---|
id |
string |
|
label |
string |
Shown in the menu and on the chip. |
icon |
LucideIcon |
|
activity |
string |
What the trace says while this tool works, e.g. "Searching the web". |
placeholder? |
string |
Placeholder while the tool is picked. |
readsSources? |
boolean |
True when the tool reads sources, so the trace stacks them up. |
limit? |
number |
Runs left today. The menu shows them as dots and locks the tool at zero. |
hint? |
string |
One quiet line under the label in the menu. |
color? |
string |
Any CSS color. Tints the icon tile, the pill and the caret. |
SearchSource
| Field | Type | Description |
|---|---|---|
domain |
string |
e.g. "developer.mozilla.org" |
title |
string |
|
icon? |
ReactNode |
The site's mark, e.g. a favicon or logo. Wins over the letter avatar. |
color? |
string |
Brand colour for the letter avatar; without it, one is derived. |
Source
"use client";
/**
* @author: @kokonutui
* @description: AI Input Search
* @version: 4.0.0
* @date: 2026-10-18
* @license: MIT
* @website: https://kokonutui.com
* @github: https://github.com/kokonut-labs/kokonutui
*/
import { ... } from "lucide-react";
import { AnimatePresence, MotionConfig, motion } from "motion/react";
import { ... } from "@/components/ui/dropdown-menu";
import { Textarea } from "@/components/ui/textarea";
import { ... } from "@/hooks/use-auto-resize-textarea";
import { cn } from "@/lib/utils";
... // Rest of the code
Usage
Pick a tool from Tools, or type / in an empty box and press its number, and the Tools pill turns into that tool, tinted with its color. Its x, picking it again, or Backspace in an empty box takes it off. A tool with a limit shows the runs left as dots and locks at zero. With no onSearch the component plays a pretend run. Wire it to your own backend by calling onSource as each source comes in and resolving when the answer is ready. A source shows as a letter avatar in its brand color; pass icon to use a logo instead. Enter or the Ask key sends, and the key turns into Stop while a run is going. Stop, or Esc, aborts signal.
<AI_Input_Search
onSearch={async (query, { tool, model, files, signal, onSource }) => {
if (!tool?.readsSources) {
return ask(query, { tool: tool?.id, model, files, signal });
}
for await (const source of mySearch(query, { deep: tool.id === "investigate", signal })) {
onSource({ domain: source.host, title: source.title });
}
}}
/>
Bring your own tools with any Lucide icon:
import { Map } from "lucide-react";
<AI_Input_Search
defaultTool={null}
tools={[
{ id: "places", label: "Find places", icon: Map, color: "#14b8a6", hint: "Maps, hours and reviews", activity: "Looking up places", readsSources: true },
]}
/>