Prompt Input
A composable prompt composer built on InputGroup with spring auto-resize, IME-safe Enter submission, drag-drop and paste file attachments, and a status-morphing submit action.
Customize
Installation
npx shadcn@latest add @kinetic/prompt-inputUsage
Build the composer from PromptInput, PromptInputAttachments, PromptInputBody, PromptInputTextarea, PromptInputFooter, PromptInputTools, and PromptInputSubmit.
import {
PromptInput,
PromptInputAttachment,
PromptInputAttachments,
PromptInputBody,
PromptInputButton,
PromptInputFooter,
PromptInputSubmit,
PromptInputTextarea,
PromptInputTools,
} from "@/components/kinetic/ui/prompt-input";
export function ChatComposer() {
return (
<PromptInput onSubmit={(msg) => console.log(msg.text, msg.files)}>
<PromptInputAttachments>
{(file) => <PromptInputAttachment data={file} />}
</PromptInputAttachments>
<PromptInputBody>
<PromptInputTextarea placeholder="Ask anything..." />
</PromptInputBody>
<PromptInputFooter>
<PromptInputTools>
<PromptInputButton>Model</PromptInputButton>
</PromptInputTools>
<PromptInputSubmit />
</PromptInputFooter>
</PromptInput>
);
}Attachments and keyboard guards
Pressing Enter submits when not holding Shift and not inside an active IME composition session. Dropping files onto PromptInput, pasting clipboard files, or calling openFileDialog() from usePromptInputAttachments() populates PromptInputAttachments with popIn chips and automatic object URL cleanup on removal or unmount.
import { PaperClipIcon } from "@heroicons/react/24/outline";
import {
PromptInputButton,
usePromptInputAttachments,
} from "@/components/kinetic/ui/prompt-input";
interface AttachControlProps {
readonly label: string;
}
export function AttachControl({ label }: AttachControlProps) {
const { openFileDialog } = usePromptInputAttachments();
return (
<PromptInputButton aria-label={label} onClick={openFileDialog}>
<PaperClipIcon className="size-4" />
</PromptInputButton>
);
}Motion preferences
PromptInput shares speed (0.45 default) and blurPx (8 default) with InputGroupTextarea, attachment chips, PromptInputSubmit status transitions, and invalid-submit shake feedback.
API Reference
PromptInput
InputGroup-backed prompt composer with drag-drop highlight, file URL lifecycle cleanup, validation shake, and shared motion props.
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onValueChange | string / string / (value: string) => void | "" | Controlled or initial prompt string. |
status | "ready" | "submitted" | "streaming" | "error" | "ready" | Drives submit button morphing between send, Spinner, stop, and error states. |
maxRows | number | 6 | Maximum visible textarea rows before internal vertical scrolling. |
validate / onSubmit / onStop | (message: PromptInputMessage) => boolean | string / ... / () => void | - | Optional custom validator triggering shake feedback, plus submit and stop callbacks. |
animated / speed / blurPx / disabled | boolean / number / number / boolean | true / 0.45 / 8 / false | Tunes blur-drift, popIn chips, status swaps, and validation shake. |
PromptInputTextarea / PromptInputSubmit / PromptInputAttachments / PromptInputAttachment / usePromptInputAttachments
Auto-resizing InputGroupTextarea, directional-swap submit control, popIn attachment chips, and attachment hook.
| Prop | Type | Default | Description |
|---|---|---|---|
autoResize / minRows / maxRows (PromptInputTextarea) | boolean / number / number | true / 2 / 6 | Spring-driven height expansion bounds on the inner textarea. |
data / onRemove (PromptInputAttachment) | PromptInputAttachmentData / (id?: string) => void | - | Attachment payload and removal callback. |