Questionnaire
A step-by-step form with selectable answers, keyboard shortcuts, validation and progress, built on UI SDK core and its radio, checkbox and input components.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/questionnaireThis adds components/keyframery/questionnaire.tsx and its primitive to your project, and installs UI SDK, along with button, checkbox, input, radio, which it builds on. The motion tokens are added to your global CSS the first time you install a component.
Usage
import {
Questionnaire,
QuestionnaireActions,
QuestionnaireChoice,
QuestionnaireChoiceDescription,
QuestionnaireChoices,
QuestionnaireDescription,
QuestionnaireError,
QuestionnaireInput,
QuestionnaireItem,
QuestionnaireItems,
QuestionnaireNext,
QuestionnairePrevious,
QuestionnaireProgress,
QuestionnaireSkip,
QuestionnaireSubmit,
QuestionnaireTitle,
} from "@/components/keyframery/questionnaire"Motion
| Move | What you see |
|---|---|
| Direction | Questions enter from the navigation direction while the previous question leaves. |
| Cascade | Each question’s title, description, answers and error arrive in order. |
| Glide | A single selection ring moves between radio answer cards. |
| Roll | The question number rolls and the progress fill grows on a spring. |
| Height | Validation errors open beneath the answers. |
Timing and springiness follow the motion style you set. To change how fast this questionnaire moves, pass speed:
<Questionnaire speed="fast">
…
</Questionnaire>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--questionnaire-face | Answer surface | bg-background |
--questionnaire-accent | Progress and selection | bg-primary |
--questionnaire-muted | Hints and progress | text-muted-foreground |
--questionnaire-radius | Answer corners | rounded-[12px] |
--questionnaire-font | Answer size | text-[13px] |
--questionnaire-gap | Section spacing | gap-5 |
--questionnaire-inset-x | Answer padding | px-3 |
API reference
Every part takes className and children, along with the props of the element it renders. The parts are rendered by UI SDK, so they also take render, to draw your own element, and a function of their state for className and style.
Questionnaire
Renders a <form>, and takes its props too.
Prop
Type
QuestionnaireChoice
Renders a <label>, and takes its props too.
Prop
Type
QuestionnaireChoices
Renders a <div>, and takes its props too.
Prop
Type
QuestionnaireInput
Renders a <input>, and takes its props too.
Prop
Type
QuestionnaireNext
Renders a <span>, and takes its props too.
Prop
Type
QuestionnairePrevious
Renders a <span>, and takes its props too.
Prop
Type
QuestionnaireSkip
Renders a <span>, and takes its props too.
Prop
Type
QuestionnaireSubmit
Renders a <span>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
QuestionnaireActions: a<div>QuestionnaireChoiceDescription: a<span>QuestionnaireDescription: a<p>QuestionnaireError: a<p>QuestionnaireItem: a<fieldset>QuestionnaireItems: a<div>QuestionnaireProgress: a<div>QuestionnaireTitle: a<legend>QuestionnaireChoiceControl: a<div>QuestionnaireChoiceLabel: a<span>QuestionnaireChoiceShortcut
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves through answers and navigation actions. |
| Arrow Up / Arrow Down | Moves between radio answers; moves focus between checkbox answers. |
| Arrow Left / Arrow Right | Goes back or forward outside radio and text controls, following reading direction. |
| Enter | Continues from a selected answer. |
| Ctrl + Enter / Cmd + Enter | Continues, or submits the last question. |
| A–Z / 1–9 | Chooses an answer when matching shortcuts are enabled. |
Accessibility
Roles, keyboard and focus are declared on the component's UI SDK primitive, and state is announced through the matching ARIA attributes. More in Accessibility.
Built on UI SDK's core
UI SDK doesn't ship a questionnaire, so this one is defined with its core: one definePrimitive in components/keyframery/core/questionnaire-core.ts, with no React in it. UI SDK's adapters can render that same definition in Vue, Svelte, Solid and web components. To keep your own styling and take only the motion, import from @/components/keyframery/primitives/questionnaire.
Questions
How does the animated Questionnaire for UI SDK move?
Direction: Questions enter from the navigation direction while the previous question leaves. Cascade: Each question’s title, description, answers and error arrive in order. Glide: A single selection ring moves between radio answer cards. Roll: The question number rolls and the progress fill grows on a spring. Height: Validation errors open beneath the answers.
Do I need Motion or Framer Motion for the animated Questionnaire?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
UI SDK has no questionnaire. How is this one built on UI SDK?
Its behaviour is one definition written with UI SDK's core (definePrimitive), in components/keyframery/core/questionnaire-core.ts. Its parts are rendered by UI SDK's adapter, so they take render, state-based class names and data-slot, like every UI SDK component.
What happens to the Questionnaire when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.