Prodular UI

AI suggestion

AIPro

AI inside forms: a suggestion row under a field, ghost text that completes what someone types, and an AiFill button that writes a field with a shimmer while it works.

npx prodular-ui add ai-suggestion

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

In a form

A suggested category to accept with Tab or dismiss, and a business purpose written on request. Both wait for the person.

New expense

$1,284.50 · Oct 18
Suggested: Cloud infrastructureUsed for this merchant 9 times

Ghost text

The rest of the suggested value appears after the caret while it still matches what was typed.

TabSuggestion: Refund for duplicate charge on the October invoice. Press Tab to accept.

Press Tab to accept the suggestion, Escape to dismiss it. Try typing Request or Reset.

Anatomy

<Input value={category} onKeyDown={onKeyDown} /><AiSuggestion  label="Suggested"  reason="Used for this merchant 9 times"  onAccept={accept}  onDismiss={dismiss}>  Cloud infrastructure</AiSuggestion>

Guidance

Use it when

  • Use AiSuggestion for a single value the model is fairly sure about: a category, an assignee, a GL account. Say why in reason.
  • Use AiGhostInput for short free text where completion saves typing: subjects, titles, names.
  • Use AiFill next to a field label for longer text the person asked for: a memo, a description, a reply.
  • After an AI fill, mark the field with AiMark inline and keep it editable.

Avoid

  • Filling fields without being asked. Suggestions are offered, never applied.
  • More than one suggestion row per field, or suggestions on every field of a form. Pick the fields where the model helps most.
  • Ghost text in multi line fields or in fields with strict formats like amounts and dates.

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.

  • Never auto accept an AiSuggestion or ghost text. Apply the value only in onAccept, which fires on the Accept button or Tab.
  • Wire Tab and Escape on the field with useAiSuggestionKeys({ active, onAccept, onDismiss }). Only set active while the suggestion is visible, so Tab keeps moving focus otherwise.
  • Hide the suggestion once it is accepted, dismissed, or the person types a different value. Offer Undo after accepting.
  • While AiFill runs, pass generating to both AiFill and AiFillField and make the control readOnly. Do not let the person submit the form with a half written value.
  • After AiFill completes, show AiMark inline next to the field until the person edits the text.

API

AiSuggestion

PropTypeDefaultDescription
label / children / reasonReactNodeWhat is suggested, the suggested value and why.
onAccept() => voidRequired. Apply the value here and nowhere else.
onDismiss() => voidShows the dismiss button.
shortcutstring | null"Tab"Key hint on the accept button.

AiGhostInput

PropTypeDefaultDescription
value / onValueChangestring / (value: string) => voidControlled input value.
suggestionstring | nullThe full suggested value. Ghost text shows while it starts with value.

AiFill

PropTypeDefaultDescription
generatingbooleanfalseAnimated mark, shimmer label and aria-busy.
iconOnlybooleanfalseFor input addons. label stays the accessible name.

AiFillField

PropTypeDefaultDescription
generating / status / alignboolean / ReactNode / "center" | "start"Overlay while the field is written. start for textareas.

useAiSuggestionKeys

PropTypeDefaultDescription
options{ active, onAccept, onDismiss }Returns an onKeyDown handler for the field.

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-suggestion# or, with the registry in components.jsonnpx shadcn@latest add @prodular/ai-suggestion