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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zure/tw-style-merge

v1.4.1

Published

A Tailwind CSS plugin to merge custom styles with theme configurations.

Downloads

27

Readme

TwStyleMerge

TwStyleMerge is a Tailwind CSS plugin that simplifies the creation of reusable CSS classes directly in the tailwind.config.js file. By defining multiple properties for your classes, this plugin eliminates the need for @apply directives, streamlining your styling process and enhancing maintainability.


🛠️ Features

  • Custom Utility Classes: Define utility classes based on your Tailwind theme.
  • Variable Support: Reference existing styles defined in your tailwind.config.js file.
  • Custom Prefix: Add a unique prefix to your generated classes.

🚀 Installation

You can install the plugin using one of the following methods:

Using npm

npm install @zure/tw-style-merge

Using Yarn

yarn add @zure/tw-style-merge

Using pnpm

pnpm add @zure/tw-style-merge

⚙️ Configuration

Add the plugin to your tailwind.config.js file and define custom styles under the tw-style-merge theme key:

// tailwind.config.js
const twStyleMerge = require('@zure/tw-style-merge');

module.exports = {
  plugins: [
    twStyleMerge()
  ],
  theme: {
    "tw-style-merge": {
      "heading-1": {
        "fontFamily": "Arial",
        "color": "#000000"
      }
    }
  },
};

Note: This configuration works within theme.extend as well.

Plugin Typing in tailwind.config.js

To add typing support, use the following JSDoc Type Annotation:

/** @type {import('@zure/tw-style-merge').TwStyleMerge} */
const twStyleMerge = require('@zure/tw-style-merge');

module.exports = {
  plugins: [
    twStyleMerge()
  ],
  theme: {
    /** @type {import('@zure/tw-style-merge').TwStyleMergeNode} */
    "tw-style-merge": {
      // ...
    }
  },
};

💡 Usage

Once configured, use the generated classes in your HTML:

<h1 class="heading-1">Main heading</h1>

If you're using Tailwind CSS IntelliSense, IntelliSense will detect and suggest the configured classes seamlessly.


🔧 Advanced Options

Adding a Custom Prefix

To prefix your custom classes, configure the plugin as follows:

// tailwind.config.js
module.exports = {
  plugins: [
    twStyleMerge({ prefix: 'my-prefix' })
  ],
};

Usage:

<h1 class="my-prefix-heading-1">Main heading</h1>

Changing the Configuration Node

Customize the default configuration node (tw-style-merge) by specifying a different name:

// tailwind.config.js
module.exports = {
  plugins: [
    twStyleMerge({ node: 'custom-node-name' })
  ],
  theme: {
    "custom-node-name": {
      "heading-1": {
        "fontFamily": "Arial",
        "color": "#000000"
      }
    }
  }
};

📝 Variables Support

Leverage variables to reuse existing properties from your tailwind.config.js file:

// tailwind.config.js
const twStyleMerge = require('@zure/tw-style-merge');

module.exports = {
  plugins: [
    twStyleMerge()
  ],
  theme: {
    colors: {
      primary: {
        dark: "#0000ff"
      }
    },
    "tw-style-merge": {
      "heading-1": {
        "fontFamily": "Arial",
        "color": "$primary.dark"
      }
    }
  }
};

Variable Mapping

The plugin intelligently maps variables to their respective theme sections. For example:

| Tailwind theme | CSS Property | | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | colors | color | | spacing | width, height, padding, paddingLeft, paddingRight, paddingTop, paddingBottom, margin, marginLeft, marginRight, marginTop, marginBottom, maxWidth, maxHeight, minWidth, minHeight | | gap | gap | | fontFamily | fontFamily | | fontSize | fontSize | | fontWeight | fontWeight | | borderRadius | borderRadius | | boxShadow | boxShadow | | opacity | opacity | | zIndex | zIndex | | lineHeight | lineHeight | | letterSpacing | letterSpacing | | maxWidth | maxWidth | | maxHeight | maxHeight | | minWidth | minWidth | | minHeight | minHeight | | transitionDuration | transitionDuration | | textDecorationColor | textDecorationColor | | textDecorationThickness | textDecorationThickness | | textUnderlineOffset | textUnderlineOffset | | backgroundColor | backgroundColor | | borderColor | borderColor | | borderWidth | borderWidth | | transformOrigin | transformOrigin | | animation | animation | | transitionProperty | transitionProperty | | transitionTimingFunction | transitionTimingFunction | | transitionDelay | transitionDelay |


🤝 Contributing

Contributions are welcome! Feel free to submit issues or pull requests on GitHub.


📜 License

Licensed under the MIT License.


🌟 Thanks

Built with ❤️ for developers who value clean and reusable styles. Powered by Tailwind CSS.