quiz-ui
Components

QuizRoot

Top-level funnel wrapper. Owns the engine and renders a styled container.

Purpose

QuizRoot is the entry point for every funnel. It creates and owns a single engine instance (via QuizProvider internally) for everything nested inside it, and renders a styled container around your funnel. Every other quiz-ui component must be rendered somewhere inside a QuizRoot.

Installation

pnpm dlx shadcn@latest add @quiz-ui/quiz-root

Usage

import {
  QuizRoot,
  QuizProgress,
  QuizStep,
  QuizNavigation,
} from "@/components/ui/quiz";

<QuizRoot definition={quiz} onComplete={(answers) => submit(answers)}>
  <QuizProgress />
  <QuizStep>{/* ... */}</QuizStep>
  <QuizNavigation />
</QuizRoot>;

Props

PropTypeDefaultDescription
definitionQuizDefinitionThe funnel to run. Required.
onComplete(answers: QuizAnswers) => voidCalled once, the moment the engine reaches its last step.
childrenReact.ReactNodeThe rest of your funnel UI.
classNamestringMerged onto the container <div>.
...restReact.HTMLAttributes<HTMLDivElement>Forwarded to the container <div>.

Notes

  • onComplete fires exactly once per completion — it won't re-fire if the user navigates back and forward through an already-completed funnel.
  • The container renders as a centered card (max-w-md, bordered, padded). Override via className if you want a different shell.

On this page