Components
Questionnaire
A multi-step form with progress, back and next.
<Questionnaire questions={questions} onSubmit={save} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/questionnaire.jsonimport { 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
| Prop | Type | Default | Description |
|---|---|---|---|
questions | { id, label, options? }[] | The questions. With options it's a choice; without, free text. | |
onSubmit | (answers: Record<string, string>) => void | Called with every answer, keyed by id. | |
thanks | string | "Thanks! Your answers are in." | Shown at the end. |
className | string | Classes for the form. |
With reduced motion, the progress bar moves without animating.