Launch priceOne payment

Prompt Input

Enter sends, Shift+Enter adds a line, Escape stops an answer that is being written. One button is Send when there is something to send and Stop while an answer is arriving. It does not send while an input method is composing.

AI ChatFree246 lines · one file

Ready for AI tools one file typed props installs by name prompt included

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Layro's Prompt Input for this.
Install it: npx shadcn@latest add https://layropro.com/r/prompt-input
Import it from @/components/ui/prompt-input.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above.

When to use it

Use Prompt Input as the message box of any AI feature. It grows with the text, sends on Enter and adds a line on Shift+Enter. While status is submitting or streaming, Send becomes Stop. Put attach or model buttons in tools. For files, slash commands and @mentions, use Prompt Composer.

Usage

components/ask-box.tsx
"use client";

import * as React from "react";
import { PromptInput, type PromptStatus } from "@/components/ui/prompt-input";

export function AskBox({ ask }: { ask: (text: string, signal: AbortSignal) => Promise<void> }) {
  const [status, setStatus] = React.useState<PromptStatus>("idle");
  const controller = React.useRef<AbortController | null>(null);

  return (
    <PromptInput
      placeholder="Ask anything…"
      status={status}
      onSubmit={async (text) => {
        controller.current = new AbortController();
        setStatus("streaming");
        try {
          await ask(text, controller.current.signal);
        } finally {
          setStatus("idle");
        }
      }}
      onStop={() => controller.current?.abort()}
    />
  );
}

API

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
valuestring—
defaultValuestring—
onValueChange(value: string) => void—
onSubmit(text: string) => voidCalled with the trimmed text. The box clears itself unless `value` is controlled.
onStop() => voidCalled by Stop and by Escape while `status` is not `idle`.
statusPromptStatus`submitting` and `streaming` both turn Send into Stop. Default `idle`.
placeholderstring—
disabledboolean—
maxRowsnumberLines before the text scrolls. Default 8.
maxLengthnumberA counter appears once the text is within 20% of it.
hintReact.ReactNode | falseThe line under the box. Pass `false` to hide it.
headerReact.ReactNodeAbove the text: attachment chips, a quoted message.
toolsReact.ReactNodeBottom-left of the box: attach, model, tools.
allowEmptybooleanAllow sending with no text — when attachments alone are a message.
textareaRefReact.Ref<HTMLTextAreaElement>Reach the textarea: to focus it, or to read the caret position.
onTextareaKeyDown(e: React.KeyboardEvent<HTMLTextAreaElement>) => voidRuns before the built-in key handling. Call `preventDefault` to take the key.
autoFocusboolean—

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Layro foundations, installed alongside it

layro-themebutton

Lifetime access

Every component, and everything we ship next.

  • All 112 components, source included
  • The template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.

More in AI Chat

All AI Chat components