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

@sliit-wif/tailwindcss-dark-mode-utils

v1.1.1

Published

## Description

Downloads

3

Readme

@sliit-wif/tailwindcss-dark-mode-utils

Description

A Tailwind CSS plugin that provides custom utilities for dark mode enhancements. This plugin includes utilities for background colors, text colors, borders, shadows, and hover states specific to dark mode.

Installation

  1. Install the Plugin

    Install the plugin via npm:

    npm install @sliit-wif/tailwindcss-dark-mode-utils

    Or with yarn:

    yarn add @sliit-wif/tailwindcss-dark-mode-utils
  2. Configure Tailwind CSS

    Add the plugin to your tailwind.config.js:

    /** @type {import('tailwindcss').Config} */
    const config = {
      content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
      theme: {
        extend: {
          colors: {
            gray: {
              800: "#2d3748",
              700: "#4a5568",
              600: "#718096",
            },
            white: "#ffffff",
            "primary-light": "#3490dc",
            "primary-dark": "#1d4ed8",
          },
          boxShadow: {
            "card-dark": "0 4px 6px rgba(0, 0, 0, 0.1)",
          },
          borderRadius: {
            card: "0.5rem",
          },
          transitionProperty: {
            theme: "background-color, color, border-color, box-shadow",
          },
        },
      },
      darkMode: "class", // Enable dark mode with 'class'
      plugins: [
       require('@sliit-wif/tailwindcss-dark-mode-utils/src/Mode.js'), // Include the custom plugin
      ],
    };
    
    module.exports = config;

Usage

  1. Include the Material Icons Font

    Add the following <link> tag to your HTML file (e.g., public/index.html):

    <link
      rel="stylesheet"
      href="https://fonts.googleapis.com/icon?family=Material+Icons"
    />
  2. Apply Dark Mode Utilities

    Use the dark mode utilities in your Tailwind CSS classes. For example:

    <div class="bg-white dark:bg-gray-800 text-black dark:text-white">
      <!-- Your content here -->
    </div>

    React Component Example:

    import React, { useState } from "react";
    import "./App.css"; // Ensure Tailwind CSS is imported
    
    const App = () => {
      const [darkMode, setDarkMode] = useState(false);
    
      const toggleDarkMode = () => {
        setDarkMode(!darkMode);
        document.documentElement.classList.toggle("dark", !darkMode);
      };
    
      return (
        <div
          className={`min-h-screen ${
            darkMode ? "dark:bg-gray-800 dark:text-white" : "bg-white text-black"
          }`}
        >
          <header className="p-4 bg-primary-light dark:bg-primary-dark text-center">
            <h1 className="text-3xl font-bold">
              Tailwind CSS Dark Mode Example
            </h1>
            <button
              onClick={toggleDarkMode}
              className="mt-4 px-4 py-2 rounded bg-primary-dark text-white dark:bg-primary-light dark:text-black flex items-center justify-center"
            >
              {darkMode ? (
                <span className="material-icons mr-2">brightness_7</span> // Sun icon for light mode
              ) : (
                <span className="material-icons mr-2">brightness_4</span> // Moon icon for dark mode
              )}
              Toggle Dark Mode
            </button>
          </header>
          <main className="p-4">
            <section className="bg-gray-100 dark:bg-gray-700 p-6 rounded shadow-card-dark">
              <h2 className="text-xl font-semibold">Welcome to Dark Mode</h2>
              <p>This section will use dark mode colors when enabled.</p>
            </section>
          </main>
        </div>
      );
    };
    
    export default App;

API

Dark Mode Utilities

  • .dark\:bg-gray-800: Applies a background color of gray-800 in dark mode.
  • .dark\:text-white: Applies a text color of white in dark mode.
  • .dark\:border-gray-700: Applies a border color of gray-700 in dark mode.
  • .dark\:shadow-md: Applies a medium shadow in dark mode.
  • .dark\:hover\:bg-gray-700:hover: Changes background color on hover to gray-700 in dark mode.

License

MIT License. See the LICENSE file for details.