QuestionPrompt

The form for one question the agent asks the user. kind is single (lettered options, one choice), multi (several choices, bounded by minSelections and maxSelections) or text (a free-text area). allowCustom adds a typed answer as the last option and allowNotes adds an optional notes field. An option can carry a preview (Markdown or code): from 640px of prompt width it is shown beside the options, below that under the chosen or hovered option. The primary button reads Next while more questions follow and Send on the last one; it stays disabled until the answer is valid. Skip calls onSkip, or onSubmit({ kind: "skip" }) when onSkip is not set. initialAnswer is read only on mount, so remount with key when the question changes. QuestionTool and InputBar questionBar use this component and handle multi-step navigation for you; render it directly only for a custom flow. Related helpers: getInitialQuestionDraft, canSubmitQuestion, buildQuestionAnswer, formatQuestionAnswer.

Getting Started
$pnpm add @sinups/ai-kit @mantine/core @mantine/hooks @tabler/icons-react
Examples
Wide, with previews
Narrow
Free text
API reference
Prop
Type
Required
questions
QuestionConfig[]
Yes
questionIndex
number
No
1-based index of the active question, `1` by default
totalQuestions
number
No
onPreviousQuestion
() => void
No
onNextQuestion
() => void
No
initialAnswer
QuestionAnswer
No
Answer used to pre-fill the form when revisiting a question. Read only on mount: hosts remount the prompt (via `key`) when the active question changes.
submitLabel
string
No
Label for the primary action on the LAST question, `'Send'` by default
nextLabel
string
No
Label for the primary action when there are more questions ahead, `'Next'` by default. The host (for example QuestionTool) is expected to advance to the next question after `onSubmit` fires.
skipLabel
string
No
`'Skip'` by default
allowSkip
boolean
No
Whether the skip button is shown, `true` by default
onSubmit
(answer: QuestionAnswer) => void
Yes
onSkip
() => void
No
Called when the skip button is pressed. When provided, `onSubmit` is NOT called for the skip. When omitted, skipping is reported as `onSubmit({ kind: 'skip' })`.
className
string
No
Class name added to the root element
style
React.CSSProperties
No
Inline styles added to the root element