- Implementation
- AgentPrompt Props
- AgentPromptOption
Common Examples
To use theAgentPrompt, 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. SetselectionMode="multi" for checkbox semantics and a string[] value.Free text
WiringonOtherChange 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
Passstep={{ 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 callingonSend 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.closeai-kit.agentPrompt.otherPlaceholderai-kit.agentPrompt.sendai-kit.agentPrompt.backai-kit.agentPrompt.nextai-kit.agentPrompt.emptyErrorai-kit.agentPrompt.step
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.
headingLevelsets the question’s heading tag independently of visual size.- Close remains available while
disabledis true.