Keyframery

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.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/questionnaire

This 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

MoveWhat you see
DirectionQuestions enter from the navigation direction while the previous question leaves.
CascadeEach question’s title, description, answers and error arrive in order.
GlideA single selection ring moves between radio answer cards.
RollThe question number rolls and the progress fill grows on a spring.
HeightValidation 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.

VariableWhat it changesDefault
--questionnaire-faceAnswer surfacebg-background
--questionnaire-accentProgress and selectionbg-primary
--questionnaire-mutedHints and progresstext-muted-foreground
--questionnaire-radiusAnswer cornersrounded-[12px]
--questionnaire-fontAnswer sizetext-[13px]
--questionnaire-gapSection spacinggap-5
--questionnaire-inset-xAnswer paddingpx-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

KeyWhat it does
TabMoves through answers and navigation actions.
Arrow Up / Arrow DownMoves between radio answers; moves focus between checkbox answers.
Arrow Left / Arrow RightGoes back or forward outside radio and text controls, following reading direction.
EnterContinues from a selected answer.
Ctrl + Enter / Cmd + EnterContinues, or submits the last question.
A–Z / 1–9Chooses 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.

All components

On this page