Skip to main content

Common Examples

To use the AgentPrompt, pass a question, an options array, controlled value / onChange, and a required onClose handler. The close button is always shown and remains available while the prompt is disabled.

Selection mode

Single-select is the default. Each row is the control; the selected row is outlined. Set selectionMode="multi" for checkbox semantics and a string[] value.

Free text

Wiring onOtherChange shows the “Something else…” row. In single-select, free text is mutually exclusive with a selected row; the text is retained if the user switches back. In multi-select, free text is independent and is appended to the selected values on send.Pass allowOther={false} to hide the row even when a handler exists. Pass true without onOtherChange only in development as a misconfiguration.

Multi-step

Pass step={{ current, total }} to replace the single Send with a stepper. Wire onNext to advance; without it, Next validates but does not move. onBack is never validated.

Empty answer

Send and Next stay enabled. Submitting with no selection and no free text shows the empty-answer error instead of calling onSend or onNext.onSend and onNext receive a resolved answer: the selected option in single-select, or the checked values with non-empty free text appended in multi-select. Free-text strings pass through verbatim.

Internationalization

AgentPrompt owns these localized strings:
  • ai-kit.agentPrompt.close
  • ai-kit.agentPrompt.otherPlaceholder
  • ai-kit.agentPrompt.send
  • ai-kit.agentPrompt.back
  • ai-kit.agentPrompt.next
  • ai-kit.agentPrompt.emptyError
  • ai-kit.agentPrompt.step
Localize question and option labels before passing them. Override otherPlaceholder or emptyErrorMessage on the component, or mount AiKitIntlProvider inside CartoTheme. step receives {current} and {total}.

React Accessibility

  • The question labels the options group through aria-labelledby.
  • Single-select uses radio semantics. Multi-select uses checkbox semantics.
  • headingLevel sets the question’s heading tag independently of visual size.
  • Close remains available while disabled is true.
Last modified on August 28, 2026