Prompt Input

The box you type in: grows with the text, Enter sends, and Send becomes Stop.

Category
AI Chat
Access
Free with an account
Source
246 lines · one file
States
6 drawn

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.

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 Liro's Prompt Input for this.
Install it: npx shadcn@latest add @liro/prompt-input
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
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. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

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 reference

“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.

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

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themebutton

States

All of them are drawn by the component. None is left for you to design.

  • Empty
  • Typing
  • Submitting
  • Streaming
  • Near the limit
  • Disabled

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances