Quiz Card
Quiz Card
The QuizCard component is a call-to-action card designed to promote quiz engagement. It displays a title, description, and a button to launch a quiz in a modal. Optionally, it can include a subtle animated attention dot to draw user focus.
Features
- Styled Card: Pre-styled with background, border, and padding
- Animated Attention Dot: Optional floating red dot animation (desktop only)
- Fully Configurable: All quiz parameters can be customized
- Responsive: Works seamlessly on all screen sizes
- Reusable: Perfect for sidebars, call-to-action sections, or standalone placement
Basic Usage
import QuizCard from '@site/src/components/QuizCard';
import quizData from '@site/src/data/quiz-demo.json';
<QuizCard
quizData={quizData}
title="Test Your Knowledge"
description="Take the 5-question quiz to see how well you understand the topic."
questionCount={5}
/>
Live Preview:
Test Your Knowledge
Take the 5-question quiz to see how well you understand the topic.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
quizData | object | required | Quiz data object containing questions |
title | string | 'Test Your Knowledge' | Card heading text |
description | string | - | Optional description text below title |
buttonText | string | 'Start Quiz' | Text displayed on the quiz button |
questionCount | number | 5 | Number of questions to show |
passingScore | number | 60 | Minimum percentage to pass (0-100) |
allowRetry | boolean | true | Whether users can retry incorrect answers |
showDot | boolean | false | Show animated attention dot |
Examples
Basic Quiz Card
<QuizCard
quizData={quizData}
title="Quick Knowledge Check"
description="Test what you've learned in just 3 questions."
questionCount={3}
/>
Quick Knowledge Check
Test what you've learned in just 3 questions.
Quiz Card with Animated Dot
Perfect for drawing attention in sidebars:
<QuizCard
quizData={quizData}
title="Security Awareness Quiz"
description="Can you spot the scams? Take our quiz to find out."
questionCount={5}
passingScore={80}
showDot={true}
/>
Security Awareness Quiz
Can you spot the scams? Take our quiz to find out.
Strict Quiz Mode
No retries allowed, high passing score:
<QuizCard
quizData={quizData}
title="Certification Exam"
description="Pass this exam with 90% to earn your certificate."
questionCount={5}
passingScore={90}
allowRetry={false}
buttonText="Begin Exam"
/>
Certification Exam
Pass this exam with 90% to earn your certificate.
Custom Button Text
<QuizCard
quizData={quizData}
title="Weekly Challenge"
description="Take on this week's challenge quiz!"
buttonText="Accept Challenge"
/>
Weekly Challenge
Take on this week's challenge quiz!
In a Two-Column Layout
Combine with TwoColumnLayout for sidebar placement:
import TwoColumnLayout from '@site/src/components/TwoColumnLayout';
<TwoColumnLayout
sidebar={
<QuizCard
quizData={quizData}
title="Test Your Skills"
description="Quick 5-question quiz on what you just learned."
showDot={true}
/>
}
>
<div>
{/* Main content here */}
</div>
</TwoColumnLayout>