Skip to content
Calm motion: animations on this site only fade, with no movement

Quiz ​

Questions with choices, a check after each answer, and a score

Tests what a learner knows, one question at a time. After each answer, the quiz shows the right choice and why. For a survey with no right answers, use the questionnaire.

Basic

Question 1 of 3

Which room of a home sounds best for recording a voice?
  • questions is a list of questions. Each question has a question, a list of choices, the index of the right choice in answer, and an optional explain.
  • The learner picks a choice and presses "Check". The right choice gets a check mark and a solid edge. A wrong pick gets a cross and a dashed edge. The choices then lock.
  • A status line says "Right!" or gives the right answer, with the reason. Screen readers hear it.
  • After the last question, the quiz shows the score and emits finish with the right answers and the total. "Start again" goes back to the first question.
  • The choices of each question are native radio buttons in a group, and the focus moves to each new question. Change the words with labels or a label pack: check, next, finish, restart, right, and the functions wrong, progress, and score.

Usage ​

ts
import { BlessQuiz } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
questions*BlessQuizQuestion[]—
labelsPartial<{ check: string; next: string; finish: string; restart: string; right: string; wrong: (answer: string) => string; progress: (n: number, total: number) => string; score: (right: number, total: number) => string; }>—

Events

NamePayloadDescription
finish[right: number, total: number]

Released under the MIT License. Character names and artwork belong to their owners.