Prompt Input
Collects a prompt in a growing field, with its tools and one Send that becomes Stop.
Configurations
Supported configurations for this component.
Default
Interaction states covered by the API and the style contract.
Configurations
3 examplesDefault
1 exampleAdd to your project
One command adds this component to your project.
Run the following command. New project? Run npx shadcn@latest init first to set up Tailwind and path aliases.
npx shadcn@latest add @aicanvas/••••••••••••Light and dark both come with the install and follow the dark class on <html>, the shadcn dark mode setup (next-themes with attribute="class").
Props
Every prop this component accepts. Any other prop is forwarded to the underlying element.
PromptInput
| Prop | Type | Default | Description |
|---|---|---|---|
| status | 'ready'|'streaming' | 'ready' | `streaming` means the assistant is working: Send becomes Stop (when `onStop` is set) and Enter no longer sends. The field stays writable. |
| onStop | () => void | - | Ends the running turn. Called by the Stop button shown in Send's place while `status` is `streaming`. Without it, Send stays in place and dead during a run. |
| onSubmit | (event: React.FormEvent<HTMLFormElement>) => void | - | Called when Send is pressed or Enter is typed in the field, with the default already prevented. Never called over an empty field or during a run. |
| children | React.ReactNode | - | A PromptInputTextarea followed by a PromptInputToolbar. |
| className | string | - | Additional CSS classes applied to the root element. |
| style | React.CSSProperties | - | Inline styles applied to the root element. |
PromptInputTextarea
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled value. Pair with onChange. Leave unset for an uncontrolled field (read it from the form on submit; `name` defaults to "message"). |
| defaultValue | string | - | Initial value when uncontrolled. |
| onChange | (event: React.ChangeEvent<HTMLTextAreaElement>) => void | - | Handler called when the value changes. |
| maxRows | number | 10 | The field starts at one line, grows with the words up to this many lines, then scrolls. |
| placeholder | string | - | Placeholder text shown when the field is empty. |
| aria-label | string | 'Prompt' | The field's accessible name; it has no visible label. A `label` prop also works and is rendered visually hidden. |
| name | string | 'message' | Form field name, so an uncontrolled field is in the form's FormData. |
| onKeyDown | (event: React.KeyboardEvent<HTMLTextAreaElement>) => void | - | Runs before the Enter handling; call preventDefault to keep Enter from sending. |
| className | string | - | Forwarded to the <textarea>. |
PromptInputToolbar
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | Laid out left to right: a PromptInputTools group first, then the right-hand controls (a mic, PromptInputSubmit), which it pushes to the far end. |
| className | string | - | Forwarded to the footer row. |
| style | React.CSSProperties | - | Forwarded to the footer row. |
PromptInputTools
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | The left group: an add menu, a model picker, a removable Tag. It takes the free width, so whatever follows it in the toolbar sits at the far end; a Tag inside may shrink. |
| className | string | - | Additional CSS classes applied to the root element. |
| style | React.CSSProperties | - | Inline styles applied to the root element. |
PromptInputSubmit
| Prop | Type | Default | Description |
|---|---|---|---|
| size | 'sm'|'md'|'lg' | 'sm' | Rung on the control ladder; match the other controls in the toolbar. |
| className | string | - | Additional CSS classes applied to the root element. |
| style | React.CSSProperties | - | Inline styles applied to the root element. |