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

tailwind-color-scheme

v0.0.5

Published

Add support for dynamic color schemes in Tailwind CSS

Downloads

5

Readme

Tailwind Color Scheme Plugin


A plugin that provides dynamic color schemes at runtime through Tailwind CSS

Installation

Install the plugin from npm:

npm install --save-dev tailwind-color-scheme
# or
yarn add -D tailwind-color-scheme

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js

const colorSchemePlugin = require('tailwind-color-scheme')

module.exports = {
  theme: {
    // ...
  },
  plugins: [
    colorSchemePlugin({
      schemes: [
        // Schemes
        {
          name: 'happy',
          colors: {
            primary: 'rgb(155, 0, 121)',
            secondary: 'rgb(9, 0, 231)',
          },
        },
        {
          // Default (no name defined)
          colors: {
            primary: '#f309f3',
            secondary: 'rgb(255, 255, 255)',
            important: '#ff0000',
          },
        },
      ],

      // Other optional plugin options goes here
    }),
  ],
}

Usage

The plugin extends Tailwind's color config with all the defined colors in the provided schemes, so you can use it with any utility class that uses color (e.g. text-primary, bg-secondary and border-important)

In order to select the scheme to be used - wrap a parent of the html (usually the <html> tag) you want to apply the color scheme to, with the utility class scheme-${name} (name is the name of the scheme

<div class="scheme-happy">
  <main>
    ...
    <h3 class="text-primary">The Title of the Section</h3>
    <button class="bg-primary-500 hover:bg-primary-700 text-white">Hover me to see change</button>
    <div class="border border-important">A very important notice</div>
    ...
  </main>
</div>

Colors

The plugin uses tinycolor2 to read and parse colors. Event supported format in tinycolor2 is also supported by this plugin

Configuration

The plugins supports this configurations as second parameter object All the configurations are optional

| Key | Type | Default Value | More Info | | ---------------------- | ------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | schemeClassPrefix | string | "scheme-" | The prefix used in shceme utility classes | | schemaPropertyPrefix | string | "tw-tcs-" | Prefix for the name of CSS custom properties defined for each color in the scheme (for example --tw-tcs-primary-500 defines the color the primary in level 500 color) | | tints | number[] \| false | [50,100,200,300,400] | List of tinted variation to generate for each color. The supported values are 50, 100, 200, 300, 400. Pass false to disable tint generation. | | shades |number[] | false|[600,700,800,900] | List of shaded variation to generate for each color. The supported values are600, 700, 800, 900. Pass false to disable tint generation. | | noDefaultColor | boolean | false | If set - utility classes for colors without tint/shade level will not be generated (e.g. text-primary will not exist, but text-primary-500 will) |