Component reference

Prompt

Multi-line input with toolbar for AI/chat interfaces

Setup

import { Prompt } from '@usefragments/ui';

Examples

Basic

Simple prompt with submit button

Loading preview...

With Actions

Prompt with attachment and mode buttons

Loading preview...

With Usage

Shows token usage indicator

Loading preview...

Agent Composer

Seamless surface with the scope of the run chosen on the toolbar

Loading preview...

Loading State

During API submission

Loading preview...

Disabled

Non-interactive prompt

Loading preview...

Props

PropTypeDefaultDescription
childrenRequirednodeNot setPrompt composition using Prompt sub-components
valuestringNot setControlled input value
defaultValuestringUncontrolled default value
onChangefunctionNot setCalled when value changes
onSubmitfunctionNot setCalled on form submission
placeholderstringAsk, Search or Chat...Placeholder text for the textarea
disabledbooleanfalseDisable the entire prompt
loadingbooleanfalseShow loading state
minRowsnumber1Minimum number of visible rows
maxRowsnumber8Maximum number of visible rows
autoResizebooleantrueEnable auto-resize based on content
submitOnEnterbooleantrueSubmit on Enter (Shift+Enter for newline)
onFilesfunctionNot setCalled with files added by the attach button, a paste, or a drop anywhere on the card. Providing it enables all three.
acceptstringNot setaccept filter for the attach button's picker, e.g. "image/*"
variantenumdefaultfixedstickydefaultVisual/positioning variant
appearanceenumpanelseamlesspanelHow the card is divided up. "panel" keeps the toolbar as a filled footer under a rule; "seamless" makes the whole card one writing surface with the controls floating on it.

Usage Guidelines

When to use

  • Building chat or AI assistant interfaces
  • Need multi-line input with submit action
  • Require toolbar with actions like attachments or model selection

When not to use

  • Simple single-line text input (use Input)
  • Basic multi-line without toolbar (use Textarea)
  • Search-only interface (use Input with search variant)

Best practices

  • Always provide an onSubmit handler
  • Use loading state during API calls
  • Prompt.Textarea forwards native textarea props (autoComplete, inputMode, aria-*, data-*, handlers)
  • Prompt.Textarea composes your onChange/onKeyDown handlers with built-in submit and auto-resize behavior
  • Use appearance="seamless" for agent composers where the controls should float on the writing surface rather than sit in a footer
  • Seamless controls share the dense 32px token scale with body-sized labels and standard glyphs so mixed Prompt.Select, Prompt.Attach and Prompt.Submit rows remain optically aligned
  • Seamless secondary controls keep transparent hover and open states so they read as inline tools; only Prompt.Submit carries a persistent filled shape
  • Seamless Prompt.Submit mirrors the trailing ink gutter established by Prompt.Attach at the leading edge
  • Prompt.Submit uses a neutral inverse surface by default so the primary action stays visible without consuming semantic brand color
  • Use Prompt.ModeButton for a setting you toggle and Prompt.Select for one you pick from a list
  • Wire onFiles once: the attach button, pasting a screenshot and dropping on the card all go through it
  • Render Prompt.Attachments above Prompt.Textarea — attachments are part of the message, not a setting on it
  • Consider showing usage/token limits for AI contexts
Accessibility
  • Enter submits, Shift+Enter for newline
  • Submit button is keyboard accessible
  • Loading state prevents duplicate submissions