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

question-form

v1.0.5

Published

Add exercise questions to your projects or blogs

Readme

question-form

React component for adding exercise questions to webpages or blogs.

NPM JavaScript Style Guide

Install

npm install --save question-form

Usage

Props

  • questions (required): of type Array. The required format of the questions array is shown below.
  • color (optional -> default - '#ddd'): of type String used on for the borders of the question container.

Required format of questions

Every question should be in form of objects with three keys: name (string), options (array) and answer (number) which is the index of the answer in the options array.

Example

import React, { Component } from 'react'

import QuestionForm from 'question-form'
import 'question-form/dist/index.css'

const Page = () => {
    const questions = [
    {
        name: 'What is React?',
        options: [
            "React is this",
            "React is that",
            "React is cool"
        ],
        answer: 0
    },
    {
        name: 'What is science?',
        options: [
            "Science is bad",
            "Science is good",
            "Science is wow"
        ],
        answer: 2
    },
]

    return (
        <QuestionForm questions={questions} color='rgb(0, 140, 255)'>
    )
}
    <QuestionForm questions={questions} color='rgb(0, 140, 255)'>
)

} Result:

Result:

Preview of the question form filled with questions

And on selection:

Preview of the question form when choices are selected

answer: 0 signifies the first option in the first question is correct and answer: 2 signifies the last option in the second question is correct.

Use case - markdown blog posts

This component can be used in any framework that allows querying of markdown posts. The questions array would be added to the frontmatter of the markdown, and on querying, this component can be used with the questions property of the frontmatter assigned to the questions prop.

This example uses a Gatsby Blog.

In the post markdown file:

---
title: "Post title"
questions:
    [
        {
            name: "What is React?",
            options: ["React is this", "React is that", "React is cool"],
            answer: 0,
        },
        ...,
    ]
---

...

Wherever you query your post, you could add the following: (the query used here is as shown in gatsby-starter-blog)

import React from 'react'
import QuestionForm from 'question-form'
---
export default ({data}) => {
    const {frontmatter: {title, questions}} = data.markdownRemark;
    return (
        <div>
            <h1>{title}</h1>
            // some stuffs here
            <h2>Exercise questions</h2>
            // ensure the questions property is not null
            {questions && (
                <QuestionForm questions={questions}>

            )}
        </div>
    )
}
---
export const query = graphql`
  query($slug: String!) {
    markdownRemark(fields: { slug: { eq: $slug } }) {
      fields {
        slug
      }
      frontmatter {
        title
        questions {
            name
            options
            answer
        }
      }
    }
  }
`

You can check a practical example on my blog in this post. You'll find it at the bottom of the post

Issues and Contributions

Your contribution to this project would be highly appreciated. It could be a documentation issue, pull request, feature request, they are all welcome.

License

MIT © dillionmegida