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

super-tailwind-merge

v0.0.1

Published

Utility function to effectively merge tailwindcss in a readable format

Downloads

10

Readme

super-tailwind-merge

super-tailwind-merge is a powerful utility that combines the strengths of classnames and tailwind-merge, providing a seamless approach to merging and conditionally applying CSS classes in a concise and readable manner.

Overview

The motivation behind super-tailwind-merge is to harness the expressive and intuitive nature of classnames alongside the functionality offered by tailwind-merge, resulting in a highly productive and easily understandable function for merging CSS classes.

Why Use super-tailwind-merge?

  • Combination of classnames and tailwind-merge: This package brings together the best of both worlds, leveraging the readability and ease of use of classnames for conditional class merging, complemented by the powerful twMerge function from tailwind-merge.

  • Readable and Productive Syntax: By merging the capabilities of these two packages, super-tailwind-merge offers a supercharged, productive, and highly readable function for conditionally composing CSS classes.

Installation

To install super-tailwind-merge in your project, simply run:

npm install super-tailwind-merge
//or
yarn add super-tailwind-merge

Usage

ES6 Import

import superTwMerge from 'super-tailwind-merge';

const example1 = superTwMerge('text-red-500', { 'font-bold': true }, 'bg-blue-200');
console.log(example1); // Outputs: 'text-red-500 font-bold bg-blue-200'

const example2 = superTwMerge('text-red-500', 'bg-blue-200', {'text-black': true});
console.log(example2); // Outputs: 'bg-blue-200 text-black'

CommonJS Require

const superTwMerge = require('super-tailwind-merge');

const example1 = superTwMerge('text-red-500', { 'font-bold': true }, 'bg-blue-200');
console.log(example1); // Outputs: 'text-red-500 font-bold bg-blue-200'

const example2 = superTwMerge('text-red-500', 'bg-blue-200', {'text-black': true});
console.log(example2); // Outputs: 'bg-blue-200 text-black'

Usage

import superTwMerge from 'super-tailwind-merge';
// ...
const buttonClasses = superTwMerge(
  'px-4',
  { 'py-2': true, 'text-white': isActive },
  'bg-blue-500',
  { 'hover:bg-blue-600': true, 'cursor-pointer': isClickable }
);

// Apply the generated classes to your button element
<button className={buttonClasses}>Click Me</button>

// ...

Notes

super-tailwind-merge simplifies the process of conditional class merging, enhancing code readability and maintainability when working with Tailwind CSS and conditional class application.

Feel free to contribute or report issues on GitHub.