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

react-theme-component

v1.0.3

Published

A plug-and-play React theme toggler with dark/light mode support.

Readme

Logo

Plug-and-Play, ready-to-use, highly customizable theme component for React.js

React Theme Component

A React theme toggler with dark/light mode support based on TailwindCSS.

Table of contents

npm

Installation

This is a React.js component available through the npm registry.

Before installing, create a React.js project and this component has default features to automate theme switching for TailwindCSS, so make sure to configure it as per your requirements. Any version of react, react-dom and tailwindcss is compatible.

Installation is done using the npm install command:

npm install react-theme-component

Features

  • Ready to use, just need to inject in your code
  • Focus on high customizability
  • Compatible with any version of React.js and TailwindCSS
  • Provide custom fields for getter and setter for loose coupling
  • Would work fine with normal state, ContextAPI and State Management Libraries like Redux, Zustand
  • Provides best UI and UX by providing ways to change color accordingly.
  • Ready to push for production

Default Inputs and Fields

export default function ThemeToggler({
    mode = "class",
    getter,
    setter,
    localKey = "theme",
    icons = true,
    lightOuterColor = "#d1d5dc",
    lightInnerColor = "black",
    darkOuterColor = "black",
    darkInnerColor = "#d1d5dc",
    extras = ""
}) {
    .....
}

Examples and Usage

Here is a quick start snippet

import React from "react";
import ThemeToggler from "react-theme-component";

export default function App() {
  return (
    <>
        <p>Change Theme: </p>
        <ThemeToggler />
    </>
  );
}

can be injected with user's self-defined state:

import React, { useState } from "react";
import ThemeToggler from "./ThemeToggler";
export default function App() {
    const [isDark, setIsDark] = useState(false);
    return (
        <>
            <h1 className="text-4xl w-fit mx-auto px-5 py-3 my-2 text-slate-800 dark:text-neutral-400 dark:shadow-slate-900 rounded-2xl">{isDark ? "Dark Theme" : "Light Theme"}</h1>

            <ThemeToggler getter={isDark} setter={setIsDark} localKey={"theme-key"} />
        </>);
}

can use react-redux in case global management is required:

"themeSlice.js"


import { createSlice } from "@reduxjs/toolkit";

export const themeSlice = createSlice({
    name: "theme",
    initialState: {
        isDark: false
    },
    reducers: {
        changeTheme: (state, action) => {
            state.isDark = action.payload;
        }
    }
});

export const {changeTheme} = themeSlice.actions;

"store.js"

import { configureStore } from "@reduxjs/toolkit";
import { themeSlice } from "./themeSlice";

const store = configureStore({
    reducer: {
        theme: themeSlice.reducer
    }
});

export default store;

using in "App.js":

import React, { useState } from "react";
import ImageTitle from "./components/ImageTitle";
import ThemeToggler from "./ThemeToggler";
import { useDispatch, useSelector } from "react-redux";
import { changeTheme } from "./store/themeSlice";
export default function App() {
    const isDark = useSelector(state => state.theme.isDark);
    const dispatch = useDispatch();

    function setIsDark(input) {
        dispatch(changeTheme(input));
    }

    return (
        <>
            <h1 className="text-4xl w-fit mx-auto px-5 py-3 my-2 text-slate-800 dark:text-neutral-400 dark:shadow-slate-900 rounded-2xl">{isDark ? "Dark Theme" : "Light Theme"}</h1>

            <ImageTitle />

            <ThemeToggler mode="attribute" getter={isDark} setter={setIsDark} icons={true} darkOuterColor={"#3579e6"} darkInnerColor={"#203352"} />
        </>);
}

Contact Me

Feel free to reach out to me through the following channels:

  • Email: [email protected]
  • LinkedIn: https://www.linkedin.com/in/bhupender-kumar-sharma-2a144a2a7
  • X: https://x.com/BSharma10111

Let me know if you need help refining this further! 😊

License

MIT