PromptBox
StableA box for describing what you want made, with a Generate button and optional examples.
Also known as prompt input, generation prompt, prompt field
Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.
With example ideas
const [busy, setBusy] = useState(false);
<div className="max-w-xl">
<PromptBox
busy={busy}
examples={["Product launch banner", "Quiet desk at sunrise"]}
onGenerate={() => { setBusy(true); setTimeout(() => setBusy(false), 1500); }}
/>
</div>Click an example to fill the box, then Generate. The demo shows Generating for 1.5 seconds.
When to use it
A roomy box for describing something to make, such as an image or a draft. Enter adds a line instead of sending, because these descriptions are often long and reworked before each run.
Made of: Text box · Character count · Generate button · Example ideas
Use it for
- The input of a tool that makes images, designs or drafts.
- Offering a few example ideas that fill the box in one click.
- A Generate step that takes a while: set busy so it cannot be pressed twice.
Not for
- Chatting back and forth with the assistant: use Composer.
- Fine settings such as size, style or seed: use ParameterPanel.
Do and avoid
Do
- Use it when each submit makes something new.
- Offer two or three examples so new people see what to write.
- Keep it in the working state the whole time, so people cannot submit twice.
- Pair it with VariantGrid and CanvasPanel in a SplitCanvasTemplate.
- Set busy back to false when the run ends, or Generate stays off.
Avoid
- Do not use it for chat. Use Composer, which has Enter and Stop.
- Do not show a PromptBox and a Composer on the same screen.
- Do not use long sentences as examples. They do not fit in small buttons.
On a phone
- The text box is 16px on a touch screen so the page does not zoom on focus. It stays three rows tall and does not grow.
- Enter adds a new line, so people send with the Generate button, which has a 44px tap area on a touch screen.
- The example chips wrap onto more lines. Each keeps its size and has a 44px tap area on a touch screen.
Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| onGeneraterequired | (prompt: string) => void | none | Called with the trimmed prompt on submit. Not called when empty or busy. |
| busy | boolean | none | Disables Generate and swaps its label and icon for a spinner with Generating… |
| placeholder | string | "Describe what you want to create…" | Placeholder text for the textarea. |
| examples | string[] | [] | Prompts offered as Try pills. Clicking one replaces the textarea content. |
"Show code under the preview gives the code for the example on the stage."
In Figma
In Figma, one PromptBox switches all of this from its properties panel, across 2 variants. Each property sets the React prop beside it, so design and code use the same names.
| Figma property | React | Values |
|---|---|---|
| Busy | busy | On or off |
Tokens
Change one of these and every part that uses it follows.
--border-strong--surface--shadow-sm--lime (Generate)--fg-subtle--surface-hover--radius-control--radius-field
Built in
- It is a real form, and the text box is named "Prompt" for screen readers.
- Generate is a real button. It stays off while the box is empty or busy.
- While busy, the button text changes to "Generating…" and its spinner is read as "Loading".
- Example ideas are real buttons, so they work from the keyboard.
- Screen readers hear when generating starts and when it ends.
What you need to do
- Set doneMessage to say where the results are, such as "Done. 4 images below."
Built toward WCAG 2.2 AA and checked automatically; no independent audit yet. Read the accessibility guide