Goal quiz

Free · MITReact Native · Expo

A one-question-a-page onboarding built from an array of steps: single and multi choice, picture grids, sliders, stat pages, a timed analysing page and custom pages, with a progress bar and back navigation.

View as Markdown
Try it on your phone
Scan to open this demo in your phone's browser and use it with your fingers.

Installation

$ npx shadcn@latest add https://goodui.dev/native/r/goal-quiz.json

Then run npx expo install --fix so react-native-reanimated match your Expo SDK. Files land in components/goodui-native/goal-quiz.

Usage

import { GoalQuiz, type QuizStep } from "@/components/goodui-native/goal-quiz/goal-quiz";

const steps: QuizStep[] = [
  {
    id: "goal",
    type: "single",
    title: "What is your main goal?",
    options: [
      { id: "lose", label: "Lose weight" },
      { id: "fit", label: "Get fitter" },
    ],
  },
  { id: "days", type: "slider", title: "Days a week?", min: 1, max: 7, initial: 3, unit: "days" },
  { id: "plan", type: "analysing", title: "Building your plan", items: ["Your goal", "Your schedule"] },
];

<GoalQuiz steps={steps} onComplete={(answers) => savePlan(answers)} onExit={() => router.back()} />

When to use

Use it for
  • Onboarding that tailors the app to the person's goal before a plan or paywall.
  • Short surveys with one question per page.
Reach for something else
  • Forms with typed fields and validation: use text fields on a normal screen.
  • Feature tours: use page-dots-onboarding.

API reference

PropTypeDefault
steps*QuizStep[]—
onComplete*
Every answer by step id.
(answers: QuizAnswers) => void—
onStepChange
Called on each step, for analytics or a live preview.
(index: number, answers: QuizAnswers) => void—
onExit
Leaves the quiz from the first step.
() => void—
onSkip
Shows Skip in the header.
() => void—
labelsPartial<GoalQuizLabels>—
style
Style for the outer container.
StyleProp<ViewStyle>—
testID
Identifier for end-to-end tests.
string—

Motion and haptics

  • Pages slide in by 36 pt in the direction of travel and mirror under RTL, while the progress bar springs forward.
  • Options stagger in, and stat numbers roll up.
  • Reduced motion: pages and options fade.
  • Haptic: Tap and select cues on options, confirm on finish, a tick for each analysing row, then success.
  • Only the current page is mounted.

Accessibility

  • Options are radios or checkboxes with their state, and the title of each page is a header.
  • The progress bar reads its step number, for example Step 2 of 5.
  • Sliders use the step title as their label.

Notes for AI

  • A single-choice step advances on its own. Multi, slider and stat steps get a Continue button. Back skips analysing steps.
  • The analysing step is a timer, not real work. Use it only if the next page really is built from the answers.
  • Stat pages need a real number and a source in `note`. Do not invent figures.
  • It is full-screen: render it in a route with the header hidden.
  • Pass translated text in the steps; only the buttons come from the language pack.