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 🙏

© 2025 – Pkg Stats / Ryan Hefner

single-question-quiz-element

v0.1.6

Published

A web component for a simple quiz

Readme

single-question-quiz-element

A web component that creates an interactive quiz with a single question, multiple choice answers, and feedback.

Usage

Include the component script in your HTML. Change latest to a specific version:

<script src="https://cdn.jsdelivr.net/npm/single-question-quiz-element@latest/dist/single-question-quiz-element.umd.min.js"></script>

Then use the component in your HTML:

<single-question-quiz-element name="my-quiz">
  <form class="bg-light rounded p-4">
    <div class="quiz-question">
      <p class="mb-4 fw-bold">Your question goes here?</p>

      <div class="form-check">
        <input class="form-check-input" type="radio" name="quizOptions" id="option1" value="0" data-correct="false" />
        <label class="form-check-label" for="option1">First answer option</label>
        <aside class="alert alert-danger mt-2" style="display: none">
          Feedback shown when this incorrect answer is selected.
        </aside>
      </div>

      <div class="form-check">
        <input class="form-check-input" type="radio" name="quizOptions" id="option2" value="1" data-correct="true" />
        <label class="form-check-label" for="option2">Second answer option (correct)</label>
        <aside class="alert alert-success mt-2" style="display: none">
          Feedback shown when this correct answer is selected.
        </aside>
      </div>

      <div class="mt-3">
        <button type="submit" class="btn btn-primary" data-action="submit">Submit Answer</button>
        <button type="button" class="btn btn-secondary" style="display: none" data-action="reset">Start over</button>
      </div>
      <aside class="alert alert-secondary mt-3" style="display: none">
        Optional general explanation shown after answer is submitted.
      </aside>
    </div>
  </form>
</single-question-quiz-element>

Required HTML Structure

  • The component must contain a <form> element
  • Question options should be in <div class="form-check"> elements
  • Each option should have:
    • A radio input with name="quizOptions" and data-correct="true/false"
    • A label
    • An optional feedback <aside> that's shown when that option is selected
  • Include submit/reset buttons with data-action="submit" and data-action="reset"
  • Optional general explanation in an <aside> at the end

For many more examples, see index.html in the repository.

Styling

The component uses Bootstrap classes by default. Include Bootstrap CSS in your page for the best appearance:

<link
  href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
  rel="stylesheet"
  crossorigin="anonymous" />

Contributing

Install packages:

npm install

Run the development server (with hot reloading):

npm run dev

Lint the code:

npm run lint

Format the code:

npm run format

Build the production version:

npm run build

Publish to npm:

npm publish