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 🙏

© 2024 – Pkg Stats / Ryan Hefner

reactdarkmodecomponent

v1.0.1

Published

This is a react dark mode plugin which can be used in any project to enable dark mode just add dark in your className for tailwindcss and write your styling for dark mode Example: <div className='flex text-xs dark:text-md'></div>

Downloads

3

Readme

React DarkMode Component

This is a react dark mode component which can be used in any project using tailwindcss to enable dark mode

License

MIT

Screenshots

Component Light Mode:

App Screenshot

Component Dark Mode:

App Screenshot

Installation

1: Install the library in your React + Tailwind Project.

  npm install reactdarkmodecomponent

2: Go to Tailwind.config.js and add property darkMode: 'class' in the object exported (module.exports).

  const plugin = require('tailwindcss/plugin')
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}",],
  darkMode: 'class',
  theme: {
    extend: {textShadow: {
      sm: '0 1px 2px var(--tw-shadow-color)',
      DEFAULT: '0 2px 4px var(--tw-shadow-color)',
      lg: '0 8px 16px var(--tw-shadow-color)',
    },},
  },
  plugins: [
    plugin(function ({ matchUtilities, theme }) {
      matchUtilities(
        {
          'text-shadow': (value) => ({
            textShadow: value,
          }),
        },
        { values: theme('textShadow') }
      )
    }),
  ]
}

3: Now in your tailwind classes add dark: and type your required styling for dark mode, these will be applied automatically if you are already in default dark mode, you can check the switch toggle component on UI from this library, if you turn off the dark mode, classes of dark: will no longer be applicable. Example:

  <div data-testid="DarkModePlugin_Container" className="flex flex-row w-fit h-fit gap-1 p-[0.4rem] items-center rounded-full border-2 shadow-md shadow-gray-500 border-indigo-400 dark:bg-slate-700 dark:shadow-gray-700 dark:border-indigo-700 bg-slate-200">

4: Import and use it in your navbar to be used with the whole project, without props for default styling coming from component itself:

  import DarkModePlugin from 'reactdarkmodecomponent';

  <DarkModePlugin/>

5: Use with props for custom styling using tailwindcss:

  <DarkModePlugin
   containerClassName='bg-blue-500'
   sunClassName='text-[1rem] text-yellow-200'
   moonClassName='text-[1rem] text-purple-300'
  />

Features

  • Light/dark mode toggle
  • Default mode apply from browser
  • Dark class for custom css to be used for dark mode

Demo

Insert gif or link to demo

https://github.com/MoeezAmir12/ReactDarkModePluginRollup/blob/main/src/Desktop2024.04.27-00.52.37.04-ezgif.com-crop.gif

Authors