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

@adnanwani/universal-darkmode

v1.1.1

Published

Zero-config dark mode for React applications with Tailwind CSS. Add dark mode to your entire application with JUST TWO LINES OF CODE! ## Features

Readme

React Dark Mode Library

Zero-config dark mode for React applications with Tailwind CSS. Add dark mode to your entire application with JUST TWO LINES OF CODE!

Features

  • 🌓 Smooth dark/light mode transitions
  • 💾 Persists user preferences
  • 🎨 Customizable styling
  • 🎯 Selective dark mode exclusion
  • 📱 Fully responsive
  • ⚛️ React 18+ support
  • 🎨 Tailwind CSS integration

Installation

npm install @adnanwani/universal-darkmode

Quick Start

  1. Wrap your app with DarkModeProvider:
import { DarkModeProvider } from '@adnanwani/universal-darkmode';

function App() {
  return (
    <DarkModeProvider>
      {/* Your app content */}
    </DarkModeProvider>
  );
}
  1. Add the toggle button wherever you want:
import { DarkModeToggle } from '@adnanwani/universal-darkmode';

function Navbar() {
  return (
    <nav>
      <DarkModeToggle />
    </nav>
  );
}
  1. Configure Tailwind CSS:
// tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  darkMode: 'class',
  theme: {
    extend: {},
  },
  plugins: [],
}

Usage

Basic Example

import { DarkModeProvider, DarkModeToggle } from '@adnanwani/universal-darkmode';

function App() {
  return (
    <DarkModeProvider>
      <div className="min-h-screen p-8">
        <DarkModeToggle className="mb-4" />
        <div className="p-6 rounded-lg border">
          <h1 className="text-2xl font-bold">Hello Dark Mode!</h1>
          <p>This content will automatically adapt to dark mode.</p>
        </div>
      </div>
    </DarkModeProvider>
  );
}

Excluding Elements from Dark Mode

Use the no-dark-mode class to keep elements in their original styling:

<div className="p-6 rounded-lg no-dark-mode bg-blue-100">
  <h2 className="text-blue-900">This stays blue in both modes!</h2>
</div>

Using the Dark Mode Hook

import { useDarkMode } from '@adnanwani/universal-darkmode';

function CustomComponent() {
  const { isDarkMode, toggleDarkMode } = useDarkMode();

  return (
    <div>
      <p>Current mode: {isDarkMode ? 'Dark' : 'Light'}</p>
      <button onClick={toggleDarkMode}>Toggle</button>
    </div>
  );
}

Provider Options

<DarkModeProvider defaultDark={true}>
  {/* Content */}
</DarkModeProvider>

| Prop | Type | Default | Description | |------|------|---------|-------------| | defaultDark | boolean | false | Initial dark mode state | | children | ReactNode | - | Child components |

Toggle Button Props

<DarkModeToggle className="custom-class" />

| Prop | Type | Default | Description | |------|------|---------|-------------| | className | string | '' | Additional CSS classes |

Styling

The library automatically handles dark mode transitions and applies appropriate styles based on the current theme. It uses CSS variables for theme colors which can be customized in your CSS:

:root {
  --bg-primary: #ffffff;
  --text-primary: #000000;
  --border-color: #e5e7eb;
}

.dark {
  --bg-primary: #1a1a1a;
  --text-primary: #ffffff;
  --border-color: #374151;
}

Browser Support

  • Chrome (and Chromium-based browsers)
  • Firefox
  • Safari
  • Edge

Requirements

  • React 18 or higher
  • Tailwind CSS 3.0 or higher

License

MIT