A chat input where how long you hold send sets how hard the AI thinks.
Type a prompt and tap send or press Enter to send it. Hold either one instead to charge it: the button fills with color and the bars light up as it climbs from Quick to Think to Think deeply. Letting go sends at that level. Press Escape or drag off the button to cancel a charge. When you send, the words rise out of the box.
Options you can pass to customize this component.
onSubmit(prompt: string, effort: PromptEffort) => voidCalled on send with the trimmed prompt and the effort it was charged to. A tap sends at the first effort.
effortsPromptEffort[]The levels a hold climbs through, each an id, a label, and an optional hex color. Each level takes 650ms; pass one level to turn charging off.
statusidlestreamingStreaming turns the send button into a stop button, ringed in the color of the effort it was sent at. You can still type, but sending waits until it is idle.
onStop() => voidCalled when the stop button is pressed while streaming.
placeholderstringstring[]Pass an array to rotate through them every 3.2 seconds while the box is empty.
hintReactNodeShown next to the send button once there is text. Pass null to hide it.
actionsReactNodeButtons for the left side of the bottom row, like attach or web search.
valuestringPass this to control the text. Pair it with onValueChange.
defaultValuestringThe text on first render.
onValueChange(value: string) => voidCalled with the new text on every edit, and with an empty string after a send.
disabledbooleanDims the box and blocks typing and sending.
inputRefRef<HTMLTextAreaElement>A ref to the textarea, for focusing it after a send or on page load.
inputPropsTextareaHTMLAttributesExtra props for the textarea, like name, id, autoFocus, or maxLength. Its key and blur handlers run before the box's own; call preventDefault in onKeyDown to stop Enter from sending.
classNamestringExtra classes merged onto the root element (data-slot="prompt-box", with data-status). The width defaults to 560px, and the text grows to 192px before it scrolls.
npx shadcn@latest add swamimalode07/rare-ui/prompt-box"use client"import { useState } from "react"import { PromptBox, type PromptBoxStatus } from "@/components/ui/prompt-box"export function Chat() {const [status, setStatus] = useState<PromptBoxStatus>("idle")return (<PromptBoxstatus={status}placeholder={["Ask anything", "Plan a weekend in Kyoto"]}onSubmit={async (prompt, effort) => {setStatus("streaming")// effort.id is "quick", "think", or "deep"await sendToModel(prompt, effort.id)setStatus("idle")}}onStop={() => setStatus("idle")}/>)}
Click the code icon in the top-right corner to view the source code.
Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.
1