---
title: "Questionnaire"
description: "Asks one question at a time, with choices or text answers. People can skip, use keys, and check every answer on a review step before they send."
url: https://gelatinui.com/components/questionnaire
markdown_url: https://gelatinui.com/components/questionnaire.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/questionnaire"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Questionnaire

> Asks one question at a time, with choices or text answers. People can skip, use keys, and check every answer on a review step before they send.

Page: https://gelatinui.com/components/questionnaire

## When to use it

Best for: A survey or an onboarding flow that shows one question at a time, with keys and a review.

- Use it when each question needs the full focus of the reader.
- Pass `onSubmitAnswers`: a promise shows the loading Submit, and a reject keeps the answers.
- Set `review` to show all answers, with Change on each row, before the send.

## When not to use it

- For a short form that people fill at a glance, use a [Field](https://gelatinui.com/components/field.md).
- For a single yes or no, use a [Checkbox](https://gelatinui.com/components/checkbox.md).

## Notes for agents

- Each `QuestionnaireItem` is a fieldset with a `name`; the answers arrive as an object and as `FormData`.
- A `required` item needs an answer; an optional one needs an answer or a Skip.
- `shortcuts` picks the choice keys: `letters`, `numbers`, or `none`.
- Built on the `@shadcn/react` Questionnaire engine, with our Progress, Input, Textarea, Button, and Kbd.

## Anatomy

```text
Questionnaire
├─ QuestionnaireProgress (0..n)
├─ QuestionnaireCount (0..n)
├─ QuestionnaireContent (0..n)
├─ QuestionnaireItem (0..n)
│  └─ QuestionnaireChoice (0..n)
├─ QuestionnaireTitle (0..n)
├─ QuestionnaireDescription (0..n)
├─ QuestionnaireChoices (0..n)
├─ QuestionnaireChoiceDescription (0..n)
├─ QuestionnaireInput (0..n)
├─ QuestionnaireTextarea (0..n)
├─ QuestionnaireError (0..n)
├─ QuestionnaireActions (0..n)
├─ QuestionnairePrevious (0..n)
├─ QuestionnaireSkip (0..n)
├─ QuestionnaireNext (0..n)
├─ QuestionnaireSubmit (0..n)
├─ QuestionnaireKeyHint (0..n)
├─ QuestionnaireReview (0..n)
├─ QuestionnaireReviewTitle (0..n)
├─ QuestionnaireReviewList (0..n)
├─ QuestionnaireSubmitError (0..n)
└─ QuestionnaireComplete (0..n)
```

## API reference

### Questionnaire

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `item` | `string` |  | The name of the question on screen (controlled). |
| `defaultItem` | `string` |  | The name of the first question to show (uncontrolled), for a resumed flow. |
| `onItemChange` | `function` |  |  |
| `items` | `readonly QuestionnaireItemDefinition[]` |  | The questions in order, for server rendering: the engine then knows the count before the questions mount. A rendered question that is not here is left out (a dev warning says so). List the `choices` of each question too: a choice that is not here gets no shortcut key. |
| `shortcuts` | `QuestionnaireShortcutMode` |  | Keys that check a choice: `letters` (A–Z) or `numbers` (1–9). Use `numbers` for scripts other than Latin. |
| `review` | `boolean` | false | Adds the review step after the last question: the Submit there reads "Review answers". |
| `density` | `"compact" \| "default"` | "default" | `default`: the page look (24px between parts, a 20px title). `compact`: a tighter look for a panel in an app (the Question Flow of the AI category): 12px between parts, the 14/20 title of a panel (the Card `sm` title), 6px between choices, and a line over the actions with 12px above them. |
| `onSubmitAnswers` | `function` |  | Sends the answers. While its promise runs, the phase is `submitting` (the Submit shows its loading look); when it resolves, `complete`; when it rejects, the answers stay and QuestionnaireSubmitError shows. Without it, the form submits as a plain form (`onSubmit`, an `action`). Catch and log your own errors inside it, then throw again to show the error. `onSubmit` runs first: a `preventDefault` there stops this call. |
| `onAnswersChange` | `function` |  | Runs after each change of an answer (and a skip), with the answers the form would send. |
| `labels` | `Partial<QuestionnaireLabels>` |  |  |

### QuestionnaireProgress

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `glow` | `boolean` |  | A soft halo in the fill color (`glow`, `@gelatin-ui/glow`). Default: `false`. |
| `tone` | `TrackTone` |  | The fill color: `default` (`primary`), or a status for a task whose state has a meaning: `success` done, `warning` slow or nearly full, `info` a neutral step, `destructive` failed. Color is never the only signal: say the state in the label or value. |

Also takes every prop of Base UI `Progress.Root`: https://base-ui.com/react/components/progress

### QuestionnaireCount

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireContent

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `invalid` | `boolean` | false |  |
| `name` | `string` |  |  |
| `multiple` | `boolean` |  |  |
| `onStatusChange` | `function` |  |  |
| `required` | `boolean` | false |  |
| `maxChoices` | `number` |  | With `multiple`: the most choices one can check. At the limit the others refuse a check. |
| `minChoices` | `number` |  | With `multiple`: the fewest choices that count as an answer. Next (and every key that goes on) stops with "Choose at least N." in the error line while 1 to N − 1 are checked. No check at all is the `required` rule. |

### QuestionnaireTitle

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `render` | `RenderProp<RenderState>` |  |  |

### QuestionnaireDescription

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `render` | `RenderProp<RenderState>` |  |  |

### QuestionnaireChoices

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `render` | `RenderProp<QuestionnaireChoicesState>` |  |  |

### QuestionnaireChoice

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `defaultChecked` | `boolean` |  |  |
| `render` | `RenderProp<QuestionnaireChoiceState>` |  |  |
| `checked` | `boolean` |  |  |
| `disabled` | `boolean` |  |  |
| `onChange` | `ChangeEventHandler` |  |  |
| `value` | `string` |  |  |

### QuestionnaireChoiceDescription

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` | `QuestionnaireInputType` |  |  |
| `size` | `"default" \| "lg" \| "sm" \| "xs"` | "lg" |  |

### QuestionnaireTextarea

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `ControlSizeAtLeastSm` |  | The padding of the box: `sm`, `default`, or `lg` (the height follows the text). |

### QuestionnaireError

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `render` | `RenderProp` |  |  |

### QuestionnaireActions

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnairePrevious

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "outline" |  |

### QuestionnaireSkip

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "ghost" |  |

### QuestionnaireNext

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "default" |  |

### QuestionnaireSubmit

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "default" |  |

### QuestionnaireKeyHint

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireReview

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireReviewTitle

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireReviewList

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `function` |  | Your own rows (`<li>`), from the answers read when the review opened. |

### QuestionnaireSubmitError

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### QuestionnaireComplete

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Questionnaire | `questionnaire` | `data-density` |  |  |
| QuestionnaireProgress | `questionnaire-progress` | `data-phase` |  |  |
| QuestionnaireCount | `questionnaire-count` |  |  |  |
| QuestionnaireContent | `questionnaire-content` | `data-phase`, `data-review` |  |  |
| QuestionnaireItem | `questionnaire-item` | `data-active`, `data-density` |  |  |
| QuestionnaireTitle | `questionnaire-title` | `data-density` |  |  |
| QuestionnaireDescription | `questionnaire-description` |  |  |  |
| QuestionnaireChoices | `questionnaire-choices` | `data-density` |  |  |
| QuestionnaireChoice | `questionnaire-choice` | `aria-invalid`, `data-checked`, `data-disabled`, `data-limit`, `data-type` | `--radius` | `motion-timing` |
| QuestionnaireChoiceDescription | `questionnaire-choice-description` |  |  |  |
| QuestionnaireInput | `questionnaire-input` |  |  |  |
| QuestionnaireTextarea | `questionnaire-textarea` |  |  |  |
| QuestionnaireError | `questionnaire-error` |  |  |  |
| QuestionnaireActions | `questionnaire-actions` | `data-density`, `data-phase` |  | `hit-area` |
| QuestionnairePrevious | `questionnaire-previous` |  |  |  |
| QuestionnaireSkip | `questionnaire-skip` |  |  |  |
| QuestionnaireNext | `questionnaire-next` |  |  |  |
| QuestionnaireSubmit | `questionnaire-submit` |  |  |  |
| QuestionnaireKeyHint | `questionnaire-key-hint` |  |  |  |
| QuestionnaireReview | `questionnaire-review` |  |  |  |
| QuestionnaireReviewTitle | `questionnaire-review-title` |  |  |  |
| QuestionnaireReviewList | `questionnaire-review-list` |  |  |  |
| QuestionnaireSubmitError | `questionnaire-submit-error` |  |  |  |
| QuestionnaireComplete | `questionnaire-complete` |  |  | `motion-timing` |

## Usage

Put each question in an item with a title and choices. Put the buttons in the actions and the thank-you text in `QuestionnaireComplete`.

```tsx title="first-week-survey.tsx"
"use client";

import {
  Questionnaire,
  QuestionnaireActions,
  QuestionnaireChoice,
  QuestionnaireChoices,
  QuestionnaireComplete,
  QuestionnaireContent,
  QuestionnaireError,
  QuestionnaireItem,
  QuestionnaireNext,
  QuestionnairePrevious,
  QuestionnaireProgress,
  QuestionnaireSubmit,
  QuestionnaireTextarea,
  QuestionnaireTitle,
} from "@/components/pro/forms/questionnaire";
import type { QuestionnaireAnswers } from "@/lib/questionnaire-state";

export function FirstWeekSurvey({
  onSave,
}: {
  onSave: (answers: QuestionnaireAnswers) => Promise<void>;
}) {
  return (
    <Questionnaire shortcuts="letters" onSubmitAnswers={onSave}>
      <QuestionnaireProgress />
      <QuestionnaireContent>
        <QuestionnaireItem name="rating" required>
          <QuestionnaireTitle>How was your first week with Lumen?</QuestionnaireTitle>
          <QuestionnaireChoices>
            <QuestionnaireChoice value="great">Great, it fits how we work</QuestionnaireChoice>
            <QuestionnaireChoice value="hard">Hard to get started</QuestionnaireChoice>
          </QuestionnaireChoices>
          <QuestionnaireError />
        </QuestionnaireItem>
        <QuestionnaireItem name="idea">
          <QuestionnaireTitle>What should we fix first?</QuestionnaireTitle>
          <QuestionnaireTextarea aria-label="What should we fix first" />
        </QuestionnaireItem>
      </QuestionnaireContent>
      <QuestionnaireActions>
        <QuestionnairePrevious />
        <QuestionnaireNext />
        <QuestionnaireSubmit />
      </QuestionnaireActions>
      <QuestionnaireComplete>
        <h2 className="text-xl font-semibold">Thanks for the feedback</h2>
      </QuestionnaireComplete>
    </Questionnaire>
  );
}
```

## Compose

Rules:

- Touch targets (`touch-targets`): Give every control a hit area of at least 44 px on touch screens, even when it looks smaller.
- Group with a Frame (`group-in-frames`): Put related panels in one `Frame` with its header and footer outside the panels, and keep a plain `Card` for one block of content.
- Name every control (`label-every-control`): Give every field a visible `Label` (or a `Field`), and every icon button a `Tooltip` or an `aria-label`.
- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/questionnaire
```

It adds 52 registry items: 48 files, 8521 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@shadcn/react`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Checkbox](https://gelatinui.com/components/checkbox.md)
- [Input](https://gelatinui.com/components/input.md)
- [Kbd](https://gelatinui.com/components/kbd.md)
- [Progress](https://gelatinui.com/components/progress.md)
- [Rolling Number](https://gelatinui.com/components/rolling-number.md)
- [Textarea](https://gelatinui.com/components/textarea.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Field](https://gelatinui.com/components/field.md)
- [Checkbox](https://gelatinui.com/components/checkbox.md)
- [Button](https://gelatinui.com/components/button.md)
- [Progress](https://gelatinui.com/components/progress.md)
- [Signature Pad](https://gelatinui.com/components/signature-pad.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Up Arrow, Down Arrow | Moves between the choices. |
| A, B, C | Picks the choice with that letter. With `shortcuts="numbers"`, the keys are 1 to 9. |
| Enter | Goes to the next question. |
| Mod+Enter | Goes on from a long answer, where Enter adds a line. |

## Motion

| Part | Motion |
| --- | --- |
| Question | popup · the next question comes in on the popup enter curve |
| Choice mark | fade · the check and the dot fade and scale in |
