# 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.

Good agents ask before guessing. When yours needs a decision, it shows the question with a small "Needs your answer" pulse. The options are rows you can pick with a click or the number keys, and "Something else" turns into a text field right in its row. Multi-choice questions toggle, each check drawing itself, and "Continue · 3" rolls its count as you pick. Once answered, the same card folds into a single line, question · answer: the options close, "Needs your answer" lifts away and the question and answer slide into its place as a check draws, so the thread stays readable.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/clarifying-question.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: `lucide-react`
- Hairline UI components it needs (the CLI installs them too): `number-roll`, `text-morph`
- Docs and live preview: https://hairlineui.com/ui/clarifying-question
- Registry item (source): https://hairlineui.com/r/clarifying-question.json

## Usage

```tsx
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={(answer) => reply(answer)}
/>
```

## With the AI SDK

```tsx
// Server: a tool with no execute; the person's answer is its output
import { tool } from "ai";
import { z } from "zod";

const askUser = tool({
  description: "Ask the user a multiple-choice question when you need a decision. Don't guess.",
  inputSchema: z.object({
    question: z.string(),
    options: z.array(z.object({ id: z.string(), label: z.string(), description: z.string().optional() })),
    multiple: z.boolean().optional(),
  }),
});

// Client: continue automatically once the answer is in
import { useChat } from "@ai-sdk/react";
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";

const { messages, addToolOutput } = useChat({ sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls });

// In your message parts:
if (part.type === "tool-askUser" && (part.state === "input-available" || part.state === "output-available")) {
  return (
    <ClarifyingQuestion
      {...part.input}
      answer={part.state === "output-available" ? part.output : undefined}
      onAnswer={(answer) => addToolOutput({ tool: "askUser", toolCallId: part.toolCallId, output: answer })}
    />
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `question / detail` | `string` | – | The question, and an optional line of context. |
| `options` | `{ id; label; description? }[]` | – | Up to nine get number keys. |
| `multiple` | `boolean` | `false` | Toggle several answers, then Continue. |
| `allowOther / otherLabel` | `boolean / string` | `true / "Something else"` | A last row that becomes a text field. |
| `onAnswer` | `(answer: { ids; labels; other? }) => void` | – | Called once with the choice. labels are ready to show or send to the model. |
| `answer` | `QuestionAnswer \| null` | – | The answer once given, e.g. the tool’s output; shows the folded line. |
| `onSkip / skipped / skippedText` | `() => void / boolean / string` | – | Offer Skip and say what happens instead. |
| `autoFocus` | `boolean` | `false` | Move focus to the first option when it appears. |

## States

- **asking**: The question, an optional detail line and numbered options. A highlight follows the pointer and arrow keys.
- **other**: "Something else…" opens a field in its row; Enter sends, Escape goes back.
- **multiple**: Checkboxes whose checks draw themselves (320ms), and Continue: " · 3" opens beside it with the first pick and the count rolls as you pick more.
- **answered**: One motion over 460ms: the options fold shut, "Needs your answer" lifts away letter by letter, the question and the answer open into the header line and the pulse blurs into a drawn check. Focus stays on the card.
- **skipped**: With onSkip, Skip folds it into "Skipped, the agent will decide".

## What it handles

Good agents ask before guessing. Without a design for it, the question is one more paragraph that the person has to answer by typing.

- **Options you can pick fast**: Click a row or press its number key. The first nine options get numbers.
- **“Something else” in place**: The last row turns into a text field right where it is.
- **Multiple choice**: Checks draw themselves and “Continue · 3” rolls its count as you pick.
- **It folds into a receipt**: Once answered, the same card becomes one line: the question and the answer.
- **It can be skipped**: With onSkip, the card folds into “Skipped, the agent will decide”.
- **Ready to send**: onAnswer gives you the chosen ids, their labels and any text typed, ready for the model.

## Replaces

a question message, option buttons, a free-text fallback, number key shortcuts, an answered state

## Where it fits

- **AI agents that need a decision**: Ask which option to take before the agent acts, instead of guessing.
- **Onboarding assistants**: Ask a few setup questions with quick answers.
- **Multi-choice questions in chat**: Let people tick several options and continue.
- **Workflow builders**: A step that pauses until the person chooses.

## Notes

- Options are a radio group (or checkboxes when multiple) labelled by the question; arrow keys move and number keys pick.
- Number keys also work when nothing else has focus, but never while typing in a field.
- A status region announces the question and the answer that was sent; the folded options are inert.
- Installs Number roll and Text morph. The fold animates the card’s real height and, like the rest, is skipped with reduced motion.

License: MIT (https://hairlineui.com/license#components)
