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
"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.
| Type | Notes | ||
|---|---|---|---|
value | string | No | – |
defaultValue | string | No | – |
onValueChange | (value: string) => void | No | – |
onSubmit | (text: string) => void | No | Called with the trimmed text. The box clears itself unless `value` is controlled. |
onStop | () => void | No | Called by Stop and by Escape while `status` is not `idle`. |
status | PromptStatus | No | `submitting` and `streaming` both turn Send into Stop. Default `idle`. |
placeholder | string | No | – |
disabled | boolean | No | – |
maxRows | number | No | Lines before the text scrolls. Default 8. |
maxLength | number | No | A counter appears once the text is within 20% of it. |
hint | React.ReactNode | false | No | The line under the box. Pass `false` to hide it. |
header | React.ReactNode | No | Above the text: attachment chips, a quoted message. |
tools | React.ReactNode | No | Bottom-left of the box: attach, model, tools. |
allowEmpty | boolean | No | Allow sending with no text — when attachments alone are a message. |
textareaRef | React.Ref<HTMLTextAreaElement> | No | Reach the textarea: to focus it, or to read the caret position. |
onTextareaKeyDown | (e: React.KeyboardEvent<HTMLTextAreaElement>) => void | No | Runs before the built-in key handling. Call `preventDefault` to take the key. |
autoFocus | boolean | No | – |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themebuttonStates
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