Components
One-Question Form
A form that asks one question at a time.
<OneQuestionForm questions={questions} onSubmit={save} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/one-question-form.jsonimport { OneQuestionForm } from "@/components/one-question-form"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 conversational form that asks one question at a time in large type. Enter moves on, each question slides in, and focus follows to the new field.
import { OneQuestionForm } from "@/components/one-question-form";
const questions = [
{ id: "name", label: "First, what's your name?" },
{ id: "company", label: "Where do you work?", placeholder: "Company name" },
];
export function Signup() {
return <OneQuestionForm questions={questions} onSubmit={(answers) => save(answers)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
questions | { id, label, placeholder? }[] | The questions, answered as text. | |
onSubmit | (answers: Record<string, string>) => void | Called with every answer. | |
thanks | string | "That's everything. Thank you!" | Shown at the end. |
className | string | Classes for the wrapper. |
With reduced motion, questions appear without sliding.