Skip to main content
Version: 1.0.3

Quiz Form

The QuizForm component provides a fully animated, multi-step survey and onboarding form interface. It supports single-choice, multiple-choice, and star/numeric rating questions, with a token-based variant system that makes adding new visual styles a zero-logic-change operation.

Question 1 of 425%
Single Choice

How did you first hear about us?

Installation

ignix add component quiz-form

Props

<QuizForm>

PropTypeDefaultDescription
questionsQuestion[]Required. Array of question objects to render.
onSubmit(answers: QuizAnswers) => voidRequired. Called with all answers when the user submits.
onStepChange(step: number, total: number) => voidundefinedFires on every navigation step change.
initialAnswersQuizAnswers{}Pre-populate answers (e.g. editing a previous submission).
cardVariant'default' | 'gradient' | 'bordered' | 'dark''default'Visual style of the question card.
showResultbooleantrueShow a results summary page after submission.
stepLabelsstring[]undefinedShort labels rendered as pill-progress above the bar (onboarding mode).
submitLabelstring'Submit'Label for the submit button on the last question.
nextLabelstring'Continue'Label for the next/continue button.
backLabelstring'Back'Label for the back button.
classNamestringundefinedExtra classes applied to the outer page wrapper.
childrenReact.ReactNodeundefinedPass sub-components directly for compound usage.
theme'light' | 'dark''light'theme selection.

Question object

FieldTypeRequiredDescription
idstringUnique identifier; used as the key in the answers map.
type'single' | 'multiple' | 'rating'Determines which input control is rendered.
questionstringThe question text displayed to the user.
hintstringSecondary helper text shown below the question.
optionsstring[]For single / multipleAnswer options for choice questions.
scalenumberFor ratingNumber of steps — ≤ 5 renders stars, > 5 renders a numeric NPS row.
requiredbooleanDefaults to true. Set to false to allow skipping.

Sub-components

All sub-components consume QuizFormContext internally — they must be rendered inside a <QuizForm> provider.

ComponentDescription
QuizForm.ProgressBarAnimated progress bar with optional step-label pills.
QuizForm.QuestionCardRenders the current question with a slide transition.
QuizForm.RadioGroupSingle-choice radio button group.
QuizForm.CheckboxGroupMultiple-choice 2-column checkbox grid.
QuizForm.RatingScaleStar rating (scale ≤ 5) or numeric NPS row (scale > 5).
QuizForm.NavigationButtonsBack + Next/Submit buttons with disabled state handling.
QuizForm.ResultPageSubmission confirmation with per-question answer summary.
QuizForm.AccentBarThin accent bar using the primary theme color.

useQuizForm hook

Access the full form context from any custom sub-component:

import { useQuizForm } from '@ignix-ui/quizform';

function MyCustomControl() {
const { step, total, answers, goNext, cardVariant } = useQuizForm();
return <span>{step + 1} / {total}</span>;
}

The hook throws if called outside a <QuizForm> provider.

Examples

Feedback survey

import { QuizForm } from '@ignix-ui/quizform';

<QuizForm
questions={questions}
onSubmit={(answers) => console.log(answers)}
cardVariant="default"
showResult={true}
/>

Onboarding flow with step labels

<QuizForm
questions={onboardingQuestions}
onSubmit={handleSubmit}
stepLabels={['Role', 'Team', 'Goals', 'Experience']}
submitLabel="Finish Setup"
nextLabel="Next Step"
/>

Gradient variant

<QuizForm questions={questions} onSubmit={handleSubmit} cardVariant="gradient" />

Pre-filled answers

<QuizForm
questions={questions}
onSubmit={handleSubmit}
initialAnswers={{ q1: 'Social Media', q3: 4 }}
/>