Prodular UI

AI field actions

Pro

AI for one text field: rewrite, shorten, expand, fix, change the tone, translate or follow an instruction. Streams into the field's AI state, shows the change as a before and after diff to accept or reject, and lets people undo.

npx prodular-ui add ai-field-actions

Part of Prodular UI Pro. Preview and read the docs freely, install with a license. See pricing

A reminder email

Open AI next to the label. Try Make shorter, Change tone or Translate to Polish, then Accept and Undo. The model here is simulated and streams word by word.

A single line, with an error

Only three actions. Translate fails to show the error and Try again.

Anatomy

<AiFieldActions value={body} onValueChange={setBody} run={rewrite} label={<label htmlFor="body">Message</label>}>  <Textarea id="body" value={body} onChange={(e) => setBody(e.target.value)} /></AiFieldActions>

Guidance

Use it when

  • Long text people write in forms: emails, notes, descriptions, replies.
  • actions to offer only what makes sense for the field, like shorten for subjects.
  • Alongside a normal Textarea or Input that stays controlled by your state.

Avoid

  • Rich documents. Rich text editor has selection-based AI editing built in.
  • Generating a whole form. Use AI form fill.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Implement run(request, signal) on your server: request has action, option (tone or language), instruction and text. Return the new text as a stream of chunks, for example from the AI SDK's streamText textStream.
  • Pass the signal to fetch so Stop cancels the request.
  • Keep the field controlled: value and onValueChange on AiFieldActions and on the control itself.
  • Results are never applied without Accept. Undo is offered until the person edits the field.
  • Throw an Error with a message people can act on; it shows under the field with Try again.

API

AiFieldActions

PropTypeDefaultDescription
value / onValueChangestring / (value) => voidThe field's text.
run(request: { action, option?, instruction?, text }, signal) => AiResultCalls your model. Returns text, a promise or an async iterable of chunks.
labelReactNodeThe label row; the AI menu sits at its end.
actionsAiFieldAction[]allrewrite, shorten, expand, fix, tone, translate, custom.
tones / languagesstring[]Options for Change tone and Translate.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add ai-field-actions# or, with the registry in components.jsonnpx shadcn@latest add @prodular/ai-field-actions