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-current-hue

v0.0.5

Published

Plugin to provide current hue styles to allow adding tint hues to a subtree.

Downloads

28

Readme

Tailwind Current Hue Plugin

Tailwind plugin to provide current hue styles to allow adding tint hues to a subtree.

Tailwind Play examples: https://play.tailwindcss.com/nl89OIO9le

Why does this exist?

On occasion I've need to build components which can be tinted any color in a website's pallete. Due to the how Tailwind's class extraction works, existing ways to do this have ended up being quite verbose. This plugin aims to solve that.

Instead of:

<span class="inline-block rounded-full bg-blue-100 px-4 py-1 text-blue-800"
  >Badge</span
>

We have:

<span
  class="hue-blue inline-block rounded-full bg-current-hue-100 px-4 py-1 text-current-hue-800"
  >Badge</span
>

This lets us build components that don't need knowledge of all the possible hues, just that they work with whatever hue is currently set. Think of it a bit like CSS' current-color but for an entire range of tones.

Installation

Install from npm using your package manager of choice

$ npm install tailwind-current-hue
// or
$ yarn add tailwind-current-hue
// Or
$ pnpm tailwind-current-hue

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

// tailwind.config.js
module.exports = {
  plugins: [require('tailwind-current-hue')],
};

This will install the plugin with the default hue of "indigo". You can configure the default with an option:

// tailwind.config.js
module.exports = {
  plugins: [require('tailwind-current-hue')]({ defaultHue: 'blue' })],
};

Usage

The plugin adds a new hue to the palette (blue, indigo, red, orange, etc) called current-hue. This can be used anywhere you would otherwise use color utility styles.

| Utility class | current-hue equivalent | | ---------------------------- | ---------------------------------- | | bg-red-100 | bg-current-hue-50 | | text-blue-800 | text-current-hue-800 | | shadow-blue-200 | shadow-current-hue-200 | | group-hover:text-green-200 | group-hover:text-current-hue-200 |

The default hue is indigo (this can be configured to be a different one from the pallete via the plugin's configuration, see above); you can set the current hue by using one of the hue-* utility styles on the specific element or an ancestor element in the DOM.

<span class="hue-red">
  <!-- Some subtree where "current-hue" is now red -->
</span>

The hue can be any value in your Tailwind theme's colors.

Both the following are visually equivalent, whether you have a wrapper element or not is up to you:

<span class="hue-blue">
  <span
    class="inline-block rounded-full bg-current-hue-100 px-4 py-1 text-current-hue-800"
    >Badge</span
  >
</span>

<span
  class="hue-blue inline-block rounded-full bg-current-hue-100 px-4 py-1 text-current-hue-800"
  >Badge</span
>

You can be as elaborate as you want with:

<div class="col-span-1 hue-sky">
  <article
    class="justify-stretch group flex flex-col gap-2 rounded-md border-2 border-current-hue-200 bg-white p-6 shadow-md shadow-current-hue-100 hover:border-current-hue-300 hover:bg-current-hue-500"
  >
    <h3
      class="text-md text-center font-medium text-current-hue-900 group-hover:text-white"
    >
      Hello world
    </h3>
    <p
      class="mb-2 text-center text-sm font-normal text-current-hue-500 group-hover:text-current-hue-200"
    >
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sodales
      porta diam.
    </p>
    <button
      class="rounded-md bg-current-hue-500 px-6 py-2 text-current-hue-50 shadow-md shadow-current-hue-200 group-hover:bg-white group-hover:text-current-hue-500 group-hover:shadow-current-hue-600"
    >
      Click me
    </button>
  </article>
</div>