NextPress Starter Blog
Published on

Embed Quiz in markdown

Authors

This component is ideal for:

  • Educational apps
  • Self-assessments
  • Certification prep quizzes
  • Interactive learning with keyboard-friendly UX

Embed Quiz in markdown

Welcome to the Quiz

You’ll have 10 seconds per question.


Features & Usage

Features

Here’s a list of all features currently included in your Quiz component, along with a brief explanation of each:

FeatureDescription
1. Start Quiz ScreenDisplays a welcome screen with a “Start Quiz” button before questions begin.
2. Per-Question TimerEach question has a countdown (default: 10 seconds). Time runs out = skip.
3. Auto Advance (Optional)If autoAdvance=true, next question shows automatically after answering.
4. Manual Advance SupportIf autoAdvance=false, user must press "Next" or use Space key.
5. Keyboard ShortcutsSelect options using keys 14, press Space to go to next (manual mode).
6. Answer HighlightingAnswers turn green (correct) or red (wrong) after selection.
7. Question BreakdownAt the end, a detailed result with correct/your answers is shown.
8. Restart Quiz"Restart Quiz" button resets everything and brings you back to the Start page.
9. Responsive LayoutWorks well on both mobile and desktop (grid adapts automatically).
10. Visual Option LabelsEach option has a small badge (1–4) at the top-right to help keyboard users.
11. Dark Mode SupportAutomatically adapts to light/dark themes with Tailwind’s dark: classes.
12. Skipped/Timeout AnswersIf time runs out, the answer is marked as incorrect and recorded as "No Answer".
13. Accessible MarkupButtons are semantic and keyboard navigable (for accessibility).
14. Configurable PropsCustomize with:
  • quizData – array of questions
  • autoAdvance – boolean
  • timePerQuestion – number (in seconds)

How to Use

  1. Provide Quiz Data
const quizData = [
  {
    question: 'Fill in the blank: 5 + 7 = ___',
    blankAnswer: '12',
    type: 'blank',
  },
  {
    question: 'What is the largest planet in our solar system?',
    answers: ['Earth', 'Mars', 'Jupiter', 'Saturn'],
    correctIndex: 2,
    type: 'multiple',
  },
  // ... more questions
]
  1. Render Component
<Quiz quizData={quizData} autoAdvance={false} timePerQuestion={10} />
  1. Styling Support

Ensure you have Tailwind CSS configured and darkMode: 'class' in tailwind.config.js.

  1. Theme Switching

Support dark mode by toggling a dark class on <html> or <body> element (e.g., via next-themes).