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

vite-plugin-twneat

v0.1.6

Published

Vite plugin that organizes Tailwind responsive prefixes into something neat and readable.

Readme

vite-plugin-twneat

A Vite plugin that organizes Tailwind responsive prefixes into a neat and readable format. Only works for Tailwind v4.

Problem

When working with responsive designs in Tailwind CSS, your markup can quickly become cluttered and difficult to read:

<div className="h-[20px] w-[40px] sm:h-[30px] md:h-[40px] lg:h-[50px] sm:w-[50px] md:w-[60px] lg:w-[70px] xl:hidden">
  Content
</div>

Tailwind also does not allow you to create dynamic classes (at least as of writing this). Tailwind reads all your files and extracts all valid classes written in plain text. Previously the idea of a safelist seem to be supported explicitly in v3 (I think) but seems not to be the case anymore in v4 as it moved to a pure css config. So instead, what you can do is just chuck a bunch of classes in plaintext into a text file and tailwind will pick it up.

Solution

vite-plugin-twneat (might) help you organize your responsive classes by breakpoint, making your code more readable and maintainable:

<div
  className={twneat({
    base: "h-[20px] w-[40px]",
    sm: "h-[30px] w-[50px]",
    md: "h-[40px] md:w-[60px]",
    lg: "h-[50px] w-[70px]",
    xl: "hidden",
  })}
>
  Content
</div>

The plugin automatically generates the necessary Tailwind classes and creates safelist files to ensure all classes are available during build time.

Installation

npm install vite-plugin-twneat --save-dev

Setup

1. Add the plugin to your Vite config

// vite.config.js / vite.config.ts
import { defineConfig } from "vite";
import twneatPlugin from "vite-plugin-twneat";

export default defineConfig({
  plugins: [
    twneatPlugin({
      // Optional custom configuration
      srcDir: "src", // Default is 'src'
      twneatDir: "src/twneat", // Default is 'src/twneat'
    }),
    // Make sure to add the Tailwind plugin AFTER twneat
    // ...other plugins
  ],
});

2. Import the twneat utility in your components

import { twneat } from "vite-plugin-twneat";

function MyComponent() {
  return (
    <div
      className={twneat({
        base: "text-blue-500 p-4",
        sm: "text-red-500 p-6",
        md: "text-green-500 p-8",
        lg: "hidden text-[100px]",
        xl: "h-[calc(100%-4px)] w-[calc(100%-4px)]",
      })}
    >
      Hello World
    </div>
  );
}

How It Works and Details

  1. The plugin runs a regex and extracts all objects that has the signature twneat({})
  2. The twneat() function just concats the breakpoint with the class, then runs clsx over it and passes it to "className" or whatever you are using.
  3. All safelist files are placed in a single directory with the original file's directory and filename (slashes replaced with underscore) and then given the extension .twneat.
  4. During development, the plugin automatically updates the safelist files when you modify your code. During build, it pre-processes all files to generate safelists.
  5. "sm: h-4 p-4" etc. will become "sm:h-4 sm:p-4" but "base: h-4 p-4" becomes "h-4, p-4" - the base is dropped.
  6. You can't mark the twneat directory as gitignore - tailwind seems to ignore it in tandem when you do that.
  7. I have only tested this for react and astro, but not for anything else. However it should work on any framework.

License

MIT