Skip to Content
zjkm-ui
Components

Questionnaire

A multi-step form with progress, back and next.

Question 1 of 3: What's your role?

Props
<Questionnaire questions={questions} onSubmit={save} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/questionnaire.json
import { Questionnaire } from "@/components/questionnaire"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

A multi-step form with one question per step, a progress bar, and Back and Next. Next waits for an answer, Back keeps earlier answers, and each new step moves focus to its question so screen reader users always know where they are. Questions are a choice (with options) or free text.

import { Questionnaire } from "@/components/questionnaire";

const questions = [
  { id: "role", label: "What's your role?", options: ["Design", "Engineering", "Product"] },
  { id: "goal", label: "What are you building?" },
];

export function Onboarding() {
  return <Questionnaire questions={questions} onSubmit={(answers) => save(answers)} />;
}

Props

PropTypeDefaultDescription
questions{ id, label, options? }[]The questions. With options it's a choice; without, free text.
onSubmit(answers: Record<string, string>) => voidCalled with every answer, keyed by id.
thanksstring"Thanks! Your answers are in."Shown at the end.
classNamestringClasses for the form.

With reduced motion, the progress bar moves without animating.

On this page