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-dark-light-switch

v1.0.1

Published

CLI to setup theme toggling in React projects with custom folder structure.

Readme

A CLI tool to set up dark/light theme toggling in React projects with a professional folder structure.

Usage

Run the following command in your React project root:

npx dark-light-toggler-react

This will:

  • Create src/provider/ThemeProvider.jsx
  • Create src/components/buttons/ThemeToggle.jsx
  • Create src/hooks/useTheme.js
  • Create folders if they don't exist
  • Create or overwrite jsconfig.json for path aliases
  • Create or overwrite vite.config.js for alias and Tailwind plugin setup
  • Install lucide-react and @types/node automatically

Next Steps

  1. Add the theme script to your index.html for initial theme detection:
<script>
  (function () {
    try {
      const theme = localStorage.getItem("vite-ui-theme");
      const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
      const resolved = theme === "dark" || (!theme && prefersDark) ? "dark" : "light";
      document.documentElement.classList.add(resolved);
    } catch (_) {}
  })();
</script>
  1. Wrap your app with <ThemeProvider> in your main entry file (e.g., main.jsx).

  2. Use <ThemeToggle /> anywhere in your app.

  3. lucide-react and @types/node will be installed automatically by the CLI.

  4. jsconfig.json and vite.config.js will be set up for path aliases and Tailwind plugin.

  5. IMPORTANT: You must have Tailwind CSS v4 installed and set up with :root, .dark, and theme variables in your CSS for theme toggling to work. The CLI does not install Tailwind for you.

Example CSS Setup

Add the following to your global CSS file. You can customize colors as you need (e.g., src/index.css):

:root {
  /* Light theme variables */
  --background: #fff;
  --text: #222;
  /* ...other variables... */
}

.dark {
  /* Dark theme variables */
  --background: #222;
  --text: #fff;
  /* ...other variables... */
}

body {
  background: var(--background);
  color: var(--text);
}

Add more custom colors in :root and .dark and using the @theme directive you can then switch dark and light colors in any element.

For Example:

@theme {
  --color-button-background: var(--btn-bg-color);
}

:root {
  --btn-bg-color: #FF5656;
}

.dark {
  --btn-bg-color: #95E68B;
}

Then in the html file use the custom Tailwind class from @theme directive:

<div>
  <button className="bg-button-background">
    Click Me
  </button>
</div>

This ensures theme toggling works with Tailwind and your custom CSS variables.

## License
MIT