Clarifying Question
Clarifying Question
The agent pauses to ask. Pick with a click or a number key, or type your own; it folds into a one-line receipt.
Dependencies
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/clarifying-questionFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Usage
Reuses Number Roll and Text Morph. Demo answers stay local; connect onAnswer and onSkip to your application or AI tool output.
import { ClarifyingQuestion } from "@/components/clarifying-question";
<ClarifyingQuestion question="Which shop is this plan for?" options={[{ id: "main", label: "Main Street" }, { id: "harbour", label: "Harbour Road" }]} onAnswer={handleAnswer} />Props
| Prop | Type | Description |
|---|---|---|
| question | string | Required. Question displayed to the user. |
| detail | string | Optional. Supporting explanation below the question. |
| options | QuestionOption[] | Required. Available choices with stable IDs and labels. |
| multiple | boolean | Optional. Allow several answers, confirmed with Continue. |
| allowOther | boolean | Optional. Offer "Something else" with a field. |
| otherLabel | string | Optional. Label for the custom-answer choice. |
| answer | QuestionAnswer | null | Optional. The answer once given, e.g. the tool's output; shows the folded line. |
| onAnswer | (answer: QuestionAnswer) => void | Required. Called with the selected or custom answer. |
| onSkip | () => void | Optional. Shows Skip; the agent continues with its own choice. |
| skipped | boolean | Optional. Whether the question has been skipped. |
| skippedText | string | Optional. Text displayed for a skipped question. |
| autoFocus | boolean | Optional. Move focus into the question when it appears. |
Accessibility & motion
Options are labelled radio buttons or checkboxes. Arrow keys move between rows; number keys pick options. Enter submits custom text and Escape returns to options. Answered options are inert and a status region announces the receipt. Reduced motion disables folding, the status pulse, and text/counter movement.
pnpm dlx shadcn@4.21.5 add @cavemio/clarifying-question