Skip to Content
zjkm-ui
Components

One-Question Form

A form that asks one question at a time.

or press Enter
Props
<OneQuestionForm questions={questions} onSubmit={save} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/one-question-form.json
import { 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

PropTypeDefaultDescription
questions{ id, label, placeholder? }[]The questions, answered as text.
onSubmit(answers: Record<string, string>) => voidCalled with every answer.
thanksstring"That's everything. Thank you!"Shown at the end.
classNamestringClasses for the wrapper.

With reduced motion, questions appear without sliding.

On this page