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-resp

v1.0.0

Published

Dynamically handle responsive breakpoints in TailwindCSS classes

Downloads

3

Readme

tailwind-resp

Dynamically handle responsive breakpoints in TailwindCSS classes

tailwind-resp is a small package to dynamically join your responsive TailwindCSS classes

Gone are the days where you would type the breakpoint for every TailwindCSS class

Instead of doing this...

'md:m-3 md:hover:bg-zinc-800 md:p-3 md:text-green-400 md:font-bold md:border-2 md:border-red-400'

you could just do:

'[resp:md] m-3 hover:bg-zinc-800 p-3 text-green-400 font-bold border-2 border-red-400'

This makes it easier to read, understand and maintain complex classes. It also supports multiple breakpoints and conditionally classes as well (see usage below)

🛠️ Install

Using npm

npm i tailwind-resp

This package is ESM only. Please check out this guide on how to convert your project to ESM


🔗 Usage

tailwind-resp exports one function called resp()

import resp from 'tailwind-resp'

resp('[resp:md] m-1 hover:bg-zinc-800 p-3') // returns 'md:m-1 md:hover:bg-zinc-800 md:p-3'

// handles multiple breakpoints as well
resp('bg-zinc-800 m-10', '[resp:sm] m-5', '[resp:lg] m-10 text-lg') // returns 'bg-zinc-800 m-10 sm:m-5 lg:m-10 lg:text-lg'

// resp comes built-in with clsx support, so you can join classnames conditionally as well
resp(selected ? '[resp:sm] text-green-400 font-bold', '[resp:sm] text-red-400') // returns 'sm:text-green-400 sm:font-bold' if selected is true else 'sm:text-green-400'

🔮 API

resp(...classes)

...classes

Type: ...string (variadic)

An infinite number of strings with TailwindCSS classnames in them. These may or may not have a 'resp:breakpoint' in them.

❤️ Support

You can support further development of this project by giving it a 🌟 and help me make even better stuff in the future by buying me a ☕

Also, if you liked this repo, consider checking out my other projects, that would be real cool!


💫 Attributions and special thanks