npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-multi-quiz

v1.0.0

Published

A customizable and flexible quiz component for React applications

Readme

React Multi Quiz

npm version npm downloads License: MIT TypeScript

A highly customizable and flexible multi-quiz component for React applications. Built with TypeScript and optimized for performance.

Features:

  • 🎯 Multiple question types (single, multiple, boolean, text)
  • 🎨 Fully customizable themes with 5 pre-built options
  • ⏱️ Timer functionality with visual countdown
  • 📊 Progress tracking and question navigation
  • 🎯 Points-based scoring system
  • 📱 Responsive design for all screen sizes
  • 🚀 Performance optimized with React hooks
  • 📦 Full TypeScript support

📋 Table of Contents

📦 Installation

npm install react-multi-quiz
# or
yarn add react-multi-quiz
# or
pnpm add react-multi-quiz

🚀 Quick Start

import { Quiz, QuizQuestion } from 'react-multi-quiz';

const questions: QuizQuestion[] = [
  {
    id: '1',
    question: 'What is the capital of France?',
    type: 'single-choice',
    options: [
      { id: '1a', text: 'London', value: 'london' },
      { id: '1b', text: 'Paris', value: 'paris' },
      { id: '1c', text: 'Berlin', value: 'berlin' }
    ],
    correctAnswer: 'paris',
    points: 10
  }
];

function App() {
  return (
    <Quiz
      questions={questions}
      config={{
        title: 'My Quiz',
        showProgress: true,
        showTimer: true,
        timeLimit: 300
      }}
      onComplete={(result) => console.log('Quiz completed!', result)}
    />
  );
}
import React from 'react';
import { Quiz, QuizQuestion } from 'react-multi-quiz';

const questions: QuizQuestion[] = [
  {
    id: '1',
    question: 'What is the capital of France?',
    type: 'single-choice',
    options: [
      { id: '1a', text: 'London', value: 'london' },
      { id: '1b', text: 'Paris', value: 'paris' },
      { id: '1c', text: 'Berlin', value: 'berlin' }
    ],
    correctAnswer: 'paris',
    points: 10
  },
  {
    id: '2',
    question: 'Which programming languages are object-oriented?',
    type: 'multiple-choice',
    options: [
      { id: '2a', text: 'Java', value: 'java' },
      { id: '2b', text: 'Python', value: 'python' },
      { id: '2c', text: 'C++', value: 'cpp' },
      { id: '2d', text: 'Assembly', value: 'assembly' }
    ],
    correctAnswer: ['java', 'python', 'cpp'],
    points: 15
  }
];

function App() {
  const handleQuizComplete = (result) => {
    console.log('Quiz completed!', result);
  };

  return (
    <div style={{ maxWidth: '800px', margin: '0 auto', padding: '20px' }}>
      <Quiz
        questions={questions}
        onComplete={handleQuizComplete}
        config={{
          title: 'My Quiz',
          description: 'Test your knowledge!',
          showProgress: true,
          showTimer: true,
          timeLimit: 300, // 5 minutes
          allowRetry: true,
          showResults: true,
          showExplanations: true,
          passPercentage: 70
        }}
      />
    </div>
  );
}

export default App;

📚 API Reference

Component Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | questions | QuizQuestion[] | ✅ | - | Array of quiz questions | | config | QuizConfig | ❌ | {} | Quiz behavior configuration | | theme | QuizTheme | ❌ | default | Visual theme customization | | onComplete | (result: QuizResult) => void | ❌ | - | Quiz completion callback | | onAnswerChange | (questionId: string, answer: string \| string[]) => void | ❌ | - | Answer change callback | | onQuestionChange | (currentQuestion: number, totalQuestions: number) => void | ❌ | - | Question navigation callback | | className | string | ❌ | - | Custom CSS class name | | style | React.CSSProperties | ❌ | - | Custom inline styles |

Question Types

Single Choice

{
  id: '1',
  question: 'What is 2 + 2?',
  type: 'single-choice',
  options: [
    { id: '1a', text: '3', value: '3' },
    { id: '1b', text: '4', value: '4' },
    { id: '1c', text: '5', value: '5' }
  ],
  correctAnswer: '4',
  points: 10,
  explanation: '2 + 2 equals 4'
}

Multiple Choice

{
  id: '2',
  question: 'Select all prime numbers:',
  type: 'multiple-choice',
  options: [
    { id: '2a', text: '2', value: '2' },
    { id: '2b', text: '3', value: '3' },
    { id: '2c', text: '4', value: '4' },
    { id: '2d', text: '5', value: '5' }
  ],
  correctAnswer: ['2', '3', '5'],
  points: 15
}

Boolean

{
  id: '3',
  question: 'Is the Earth round?',
  type: 'boolean',
  correctAnswer: 'true',
  points: 5
}

Text

{
  id: '4',
  question: 'What is your favorite color?',
  type: 'text',
  required: true,
  points: 5
}

Configuration Options

const config: QuizConfig = {
  // Basic Settings
  title: 'My Quiz',                    // Quiz title
  description: 'Test your knowledge',  // Quiz description
  
  // Behavior Settings
  shuffleQuestions: true,              // Randomize question order
  shuffleOptions: true,                // Randomize option order
  showProgress: true,                  // Show progress bar
  showTimer: true,                     // Show timer
  timeLimit: 300,                      // Time limit in seconds
  allowRetry: true,                    // Allow retaking the quiz
  showResults: true,                   // Show results after completion
  showExplanations: true,              // Show explanations in results
  passPercentage: 70                   // Passing score percentage
};

Theme Customization

const theme: QuizTheme = {
  // Colors
  primaryColor: '#007bff',           // Primary button color
  secondaryColor: '#6c757d',         // Secondary button color
  backgroundColor: '#ffffff',        // Background color
  textColor: '#333333',              // Text color
  borderColor: '#dee2e6',            // Border color
  
  // Typography & Layout
  borderRadius: '8px',               // Border radius
  fontFamily: 'Arial, sans-serif',   // Font family
  fontSize: '16px'                   // Font size
};

💡 Usage Examples

Basic Implementation

import { Quiz, QuizQuestion } from 'react-multi-quiz';

const questions: QuizQuestion[] = [
  {
    id: '1',
    question: 'What is 2 + 2?',
    type: 'single-choice',
    options: [
      { id: '1a', text: '3', value: '3' },
      { id: '1b', text: '4', value: '4' },
      { id: '1c', text: '5', value: '5' }
    ],
    correctAnswer: '4',
    points: 10
  }
];

function App() {
  return (
    <Quiz
      questions={questions}
      config={{
        title: 'Math Quiz',
        showProgress: true,
        timeLimit: 300
      }}
      onComplete={(result) => console.log('Score:', result.percentage)}
    />
  );
}

Custom Theme

<Quiz
  questions={questions}
  theme={{
    primaryColor: '#e74c3c',
    backgroundColor: '#2c3e50',
    textColor: '#ecf0f1',
    borderRadius: '12px',
    fontFamily: 'Georgia, serif'
  }}
  style={{
    boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
    margin: '20px'
  }}
/>

Answer Tracking

const [answers, setAnswers] = useState({});

const handleAnswerChange = (questionId, answer) => {
  setAnswers(prev => ({
    ...prev,
    [questionId]: answer
  }));
};

<Quiz
  questions={questions}
  onAnswerChange={handleAnswerChange}
/>

Results Integration

const handleQuizComplete = (result) => {
  // Log results
  console.log('Score:', result.percentage);
  console.log('Correct Answers:', result.correctAnswers);
  console.log('Total Points:', result.totalPoints);
  console.log('Time Spent:', result.timeSpent);
  
  // Send to API
  fetch('/api/quiz-results', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(result)
  });
};

TypeScript Support

The component is fully typed with TypeScript. All interfaces are exported for your convenience:

import { 
  QuizQuestion, 
  QuizConfig, 
  QuizTheme, 
  QuizResult 
} from 'react-multi-quiz';

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

Performance

The component is optimized for performance with:

  • React.memo for component memoization
  • useCallback for stable function references
  • useMemo for expensive calculations
  • Efficient re-rendering strategies

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you have any questions or need help, please open an issue on GitHub or contact the maintainers.

📦 Package Information

  • Package: react-multi-quiz
  • Version: 1.0.0
  • Size: ~48KB (gzipped)
  • License: MIT
  • Repository: GitHub
  • Issues: GitHub Issues

📝 Changelog

v1.0.0 (Latest)

  • 🎉 Initial release
  • 🎯 Support for multiple question types (single, multiple, boolean, text)
  • 🎨 Customizable themes with 5 pre-built options
  • ⏱️ Timer functionality with visual countdown
  • 📊 Progress tracking and question navigation
  • 🎯 Points-based scoring system
  • 📱 Responsive design for all screen sizes
  • 🚀 Performance optimized with React hooks
  • 📦 Full TypeScript support
  • 🧪 Comprehensive test suite
  • 📚 Complete documentation and examples