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

tailwind-component-classes

v2.0.4

Published

Create custom classes in your tailwind config

Readme

Tailwind CSS Component Classes

This plugin is designed to use your tailwind.config.js and it's associated architecture to build up custom classes without the need to extend a custom css file.

Features

  • Simple declarative format for more complex classes
  • Use all of tailwind's existing prefixes
  • Make use of presets and the extend funcationality to share classes across projects
  • Define an optional base class that can be extended to avoid repetion (see example below)
  • Use existing declared classes to create new classes
  • Hooks into Tailwind's 3 layers: base, components & utilities

Quickstart

Here are some examples of what's possible on the Tailwind CSS Playground

  • Demo (spot the difference!): https://play.tailwindcss.com/oP6UznVP9J
  • Simple Example: https://play.tailwindcss.com/4KpGKazbeS
  • Advanced Example: https://play.tailwindcss.com/u4p5utf00J
  • Functions: https://play.tailwindcss.com/0frdJch6Fo?file=config
  • Design Library: https://play.tailwindcss.com/PCDEoF6B5w?file=config (Replicating DaisyUI Buttons - WIP)

Usage

First:

npm install tailwind-component-classes

Second:

    ...
    plugins: [
        require("tailwind-component-classes")
    ]
    ...

Third:

configure your classes in the theme section:

    ...
    theme: {...},
    components: {
        btn: "text-blue-400 bg-gray-900 border shadow border-blue-500 hover:bg-red-900",
    }
    ...

You can then do the following in your code:

<div>
    <a class="btn">This is a button</a>
</div>

Which would be the equivalent to doing:

<div>
    <a class="text-blue-400 bg-gray-900 border border-blue-500 shadow hover:bg-red-900">This is a button</a>
</div>

A more complex example

This config:

components: {
    btn: {
        _: "border-blue-400"
        primary: "bg-blue-400",
        secondary: "bg-green-400"
        error: "bg-red-400"
    },
    heading: {
        1: "text-4xl"
        2: "text-3xl"
    }
}

would be the equivalent to declaring this in a css file using the @apply rule:

.btn {
    @apply border-blue-400;
}
.btn-primary {
    @apply border-blue-400 bg-blue-400;
}
.btn-secondary {
    @apply border-blue-400 bg-green-400;
}
.btn-error {
    @apply border-blue-400 bg-red-400;
}
.heading-1 {
    @apply text-4xl;
}
.heading-2 {
    @apply text-3xl;
}

What's with the underscore in the above example?

This plugin adds an _ option when declaring an object in the components object (see the btn object in the above example). The _ key creates a base class as well as merging these base CSS classes with every other classes declared at that level. The primary motivation for this is to help reduce duplication when declaring components in the config file.

Using a preset

Additionally you can use the tailwind preset functionality to share and extend components. See the examples/advanced directory for a working example.

When using presets ensure that the plugin is only defined once otherwise classes will be generated multiple times increasing the size of the generated css file.