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

tailwind-classify

v0.1.1

Published

A lightweight utility function to merge and conditionally join class names.

Downloads

380

Readme

Tailwind Classify

A lightweight utility function to merge and conditionally join class names in JavaScript/TypeScript, built on top of clsx and tailwind-merge for optimal CSS class management.

Installation

You can install the package via npm:

  npm install tailwind-classify

Alternatively, you can install it using yarn:

  yarn add tailwind-classify

Usage

The classify function allows you to conditionally combine strings, objects, and arrays of class names. It uses clsx for merging classes and tailwind-merge to handle duplicate Tailwind CSS classes correctly.

Examples:

import { classify } from 'tailwind-classify';

// Basic usage
const buttonClass = classify('btn', 'btn-primary'); 
// Result: 'btn btn-primary'

// Handling falsy values
const buttonClass = classify('btn', false, 'btn-primary', undefined);
// Result: 'btn btn-primary' (falsy values are ignored)

// Conditional classes
const isActive = true;
const buttonClass = classify('btn', isActive && 'active');
// Result: 'btn active'

// Handling null values
const buttonClass = classify('btn', null, 'btn-primary');
// Result: 'btn btn-primary'

// Tailwind CSS class merging (removes duplicates)
const buttonClass = classify('p-4', 'bg-red-500', 'p-4');
// Result: 'p-4 bg-red-500'

API

classify(...inputs: (string | boolean | undefined | null)[]): string

  • inputs: Accepts a combination of strings, boolean values, null, or undefined values.
  • returns: A string containing the merged class names, with falsy values and duplicates removed.

Features:

  • Merges class names: Combines multiple class names into one string.
  • Removes falsy values: Filters out false, undefined, null, and similar falsy values.
  • Handles conditional classes: You can conditionally include class names based on boolean values or expressions.
  • Tailwind CSS optimization: Uses tailwind-merge to prevent duplicate Tailwind classes and optimize the output.

Example with Tailwind CSS Classes

import { classify } from 'tailwind-classify';

const classString = classify('p-4', 'bg-blue-500', 'p-4', 'text-white');
// Result: 'p-4 bg-blue-500 text-white' (duplicates removed)

Keywords

  • classify
  • tailwind
  • tailwind classify
  • tailwindcss
  • utility function
  • clsx
  • tailwind-merge
  • class merging
  • conditional classes
  • tailwind css optimization

License

This package is completely free to use and is open-source under the MIT License. You can use, modify, and distribute it however you like.