DEV Community

Bruno Noriller
Bruno Noriller

Posted on

2

EasyTailwind: a package to supercharge your Tailwind

Hello, humans!

We all love Tailwind, but there's one thing that I'm sure is not to everyone's liking:

Classes get large fast! It's messy and hard to find what is going on there...
I mean:

"text-lg font-medium text-black hover:underline hover:decoration-black sm:text-base sm:text-blue-500 sm:hover:decoration-cyan-500 lg:text-2xl lg:text-green-500 lg:hover:decoration-amber-500"
Enter fullscreen mode Exit fullscreen mode

No more! Enter EasyTailwind:

https://www.npmjs.com/package/easy-tailwind

This is a little utility to be used with Tailwind and gives you superpowers!

What if instead of writing that large class you could write:

e(
  'text-lg font-medium text-black',
  {
    hover: 'underline decoration-black',
    sm: [
      'text-base text-blue-500',
      {
        hover: 'decoration-cyan-500',
      },
    ],
    lg: [
      'text-2xl text-green-500',
      {
        hover: 'decoration-amber-500',
      },
    ],
  }
)
Enter fullscreen mode Exit fullscreen mode

Not only it's faster to write and read, but it's also easier to understand exactly what it's doing, don't you think?

Start playing around with it here: https://stackblitz.com/edit/easy-tailwind?file=src/App.jsx

And again the package: https://www.npmjs.com/package/easy-tailwind

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay