Skip to main content

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.

@heroicons/react
motion-tokens.ts

Customize

Max rows6
Speed0.45
Blur reveal (px)8

Installation

npx shadcn@latest add @kinetic/prompt-input

Usage

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.

PropTypeDefaultDescription
value / defaultValue / onValueChangestring / 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.
maxRowsnumber6Maximum 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 / disabledboolean / number / number / booleantrue / 0.45 / 8 / falseTunes 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.

PropTypeDefaultDescription
autoResize / minRows / maxRows (PromptInputTextarea)boolean / number / numbertrue / 2 / 6Spring-driven height expansion bounds on the inner textarea.
data / onRemove (PromptInputAttachment)PromptInputAttachmentData / (id?: string) => void-Attachment payload and removal callback.