Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Shared
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Hooks
Resources
Prompt Input
A composer with attachments, tools and a submit button.
"use client";
import { ArrowUpIcon, PlusIcon, SquareIcon } from "lucide-react";
import { useState } from "react";
import {
PromptInput,
PromptInputAction,
PromptInputTextarea,
} from "@/registry/default/shared/prompt-input";
import { Button } from "@/components/ui/button";
export default function Particle() {
const [value, setValue] = useState("");
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = () => {
if (!value.trim()) {
return;
}
setIsLoading(true);
setTimeout(() => {
setIsLoading(false);
setValue("");
}, 1600);
};
return (
<div className="w-full max-w-lg">
<PromptInput
isLoading={isLoading}
onSubmit={handleSubmit}
onValueChange={setValue}
value={value}
>
<PromptInputTextarea placeholder="Ask anything…" />
<div className="flex items-center justify-between">
<PromptInputAction tooltip="Attach a file">
<Button aria-label="Attach a file" size="icon-sm" variant="ghost">
<PlusIcon aria-hidden="true" />
</Button>
</PromptInputAction>
<PromptInputAction tooltip={isLoading ? "Stop" : "Send"}>
<Button
aria-label={isLoading ? "Stop" : "Send"}
onClick={handleSubmit}
shape="pill"
size="icon"
>
{isLoading ? <SquareIcon aria-hidden="true" /> : <ArrowUpIcon aria-hidden="true" />}
</Button>
</PromptInputAction>
</div>
</PromptInput>
</div>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/prompt-input
Usage
import { PromptInput, PromptInputAction, PromptInputTextarea } from "@/components/prompt-input";<PromptInput isLoading={isLoading} onSubmit={send} onValueChange={setValue} value={value}>
<PromptInputTextarea placeholder="Ask anything…" />
<div className="flex items-center justify-end gap-1 pt-2">
<PromptInputAction tooltip="Send">
<Button aria-label="Send" size="icon-sm">
<ArrowUpIcon aria-hidden="true" />
</Button>
</PromptInputAction>
</div>
</PromptInput>API Reference
PromptInput is a controlled container: it owns the value, the textarea ref and
the submit handler, and shares them with its children through context.
PromptInput
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Current text. Controlled. |
onValueChange | (value: string) => void | — | Called as the user types. |
onSubmit | () => void | — | Fired on Enter (without Shift) and by your own submit control. |
isLoading | boolean | false | Marks the composer busy; use it to swap the submit affordance. |
maxHeight | number | string | 240 | Ceiling for the auto-growing textarea. |
disabled | boolean | false | Disables the textarea and suppresses submit. |
Also accepts <div> attributes.
PromptInputTextarea
| Prop | Type | Default | Description |
|---|---|---|---|
disableAutosize | boolean | false | Keeps a fixed height instead of growing with content. |
Also accepts Textarea props. Enter submits, Shift+Enter inserts a newline.
PromptInputAction
Wraps a single control in a tooltip, so the toolbar reads consistently.
| Prop | Type | Default | Description |
|---|---|---|---|
tooltip | ReactNode | — | Tooltip content. Required. |
children | ReactElement | — | The control to wrap. A single element. |
side | "top" | "bottom" | "left" | "right" | "top" | Tooltip placement. |
Also accepts Tooltip props.
Open the source under Manual above for the exact prop types.
Examples
"use client";
import { SquareIcon } from "lucide-react";
import {
PromptInput,
PromptInputAction,
PromptInputTextarea,
} from "@/registry/default/shared/prompt-input";
import { Button } from "@/components/ui/button";
export default function Particle() {
return (
<div className="w-full max-w-lg">
<PromptInput isLoading value="Summarise the release notes">
<PromptInputTextarea disabled placeholder="Ask anything…" />
<div className="flex items-center justify-end pt-2">
<PromptInputAction tooltip="Stop generating">
<Button aria-label="Stop generating" size="icon-sm" variant="ghost">
<SquareIcon aria-hidden="true" />
</Button>
</PromptInputAction>
</div>
</PromptInput>
</div>
);
}