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

clswind

v26.12.4

Published

A lightweight utility to conditionally join Tailwind CSS classes without conflicts. Stop copy-pasting `cn` helper functions.

Readme

clswind

A tiny, fast utility for merging Tailwind CSS classes without conflicts.

npm version License

Why clswind?

Every Tailwind CSS project seems to start with the same ritual: creating a lib/utils.ts file and copy-pasting the cn helper function.

Stop copy-pasting.

clswind provides this standard utility as a package, so you can:

  • 🚀 Save time: No more boilerplate files in every project.
  • 📦 Keep it clean: One less file to maintain.
  • 🛠 Stay updated: Get improvements and fixes automatically.

Introduction

clswind combines the power of clsx and tailwind-merge into a single, easy-to-use function.

  • Conditional: Apply classes based on boolean logic (like clsx).
  • Conflict-free: Automatically resolves Tailwind CSS class conflicts (like tailwind-merge).

Installation

npm install clswind
# or
yarn add clswind
# or
pnpm add clswind

Usage

Basic Usage

It works just like clsx, but handles Tailwind conflicts intelligently.

import { cn } from "clswind";

// Basic conditional classes
cn("px-2 py-1", "bg-red-500", {
  "text-white": true,
  "text-black": false,
});
// => 'px-2 py-1 bg-red-500 text-white'

// Merging conflicting Tailwind classes
// 'p-4' overrides 'px-2 py-1' because padding utilities conflict
cn("px-2 py-1", "p-4");
// => 'p-4'

With React Components

This is especially useful when building reusable UI components that accept className props.

import { cn } from "clswind";

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: "primary" | "secondary";
  className?: string; // Explicitly define className prop if needed, though included in ButtonHTMLAttributes
}

export function Button({
  className,
  variant = "primary",
  ...props
}: ButtonProps) {
  return (
    <button
      className={cn(
        // Base styles
        "px-4 py-2 rounded font-medium transition-colors",
        // Variant styles
        variant === "primary" && "bg-blue-500 text-white hover:bg-blue-600",
        variant === "secondary" &&
          "bg-gray-200 text-gray-800 hover:bg-gray-300",
        // External classes (allows overriding base/variant styles)
        className,
      )}
      {...props}
    />
  );
}

With class-variance-authority (CVA)

clswind is the perfect companion for CVA. CVA handles your component variants, while clswind handles the class merging and conflict resolution.

import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "clswind";

const badgeVariants = cva(
  "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
  {
    variants: {
      variant: {
        default:
          "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
        secondary:
          "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
        destructive:
          "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
        outline: "text-foreground",
      },
    },
    defaultVariants: {
      variant: "default",
    },
  },
);

export interface BadgeProps
  extends
    React.HTMLAttributes<HTMLDivElement>,
    VariantProps<typeof badgeVariants> {}

function Badge({ className, variant, ...props }: BadgeProps) {
  return (
    <div className={cn(badgeVariants({ variant }), className)} {...props} />
  );
}

License

MIT © iubns