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

lite-classnames

v1.3.0

Published

A lightweight ("lite") classnames generation utility function

Readme

lite-classnames

A lightweight ("lite") classnames generation utility function.

This is a simpler alternative to the classnames package with a smaller API surface for lean classnames string generation.

It's not meant to be a 1-to-1 drop-in replacement, but rather a more opinionated lightweight approach that encourages intentional usage. It only supports the following types as input:

  • string and
  • Record<string, boolean>

Instead of supporting various input types and conditionally checking every user input, the responsibility shifts to the user to handle this programmatically. This leaves the function with less work to do, resulting in a smaller footprint and better performance.

Usage

import classNames from 'lite-classNames';
classNames('foo', 'bar', 'quux');                 // => 'foo bar quux'
classNames({ foo: true, bar: true, quux: true }); // => 'foo bar quux'
classNames('foo', { bar: true }, 'quux');         // => 'foo bar quux'

classNames('foo', { bar: false }, 'quux');         // => 'foo quux'
classNames({ foo: true, bar: false, quux: true }); // => 'foo quux'

Background

At my previous workplace, we frequently used the classnames utility function, but it became difficult to reason about due to varying preferences for how arguments were passed to the function.

We also noticed performance issues on low-end devices that caused janky CSS animations and poor user experience, since the classnames evaluation could be skipped on some animation frames.

We needed something with better performance that enforced consistent usage with fewer input options, resulting in code that was easier to understand and more performant.

This is the result of that effort.

FAQ

Why only support string and Record<string, boolean>?

To discourage multiple ways of expressing the same result in code. The current API surface provides the minimum functionality we needed to get things done.

Why no null, undefined, or number support?

Less is more. While numbers can be coerced to strings, we leave this to be handled at the call site rather than within the function itself. CSS classes are rarely numeric values alone without some string prefix/suffix.

Why no support for arrays of strings or records?

This is by design - we wanted to avoid complex and/or nested structures and prevent the need for a recursive function. You can always destructure directly in your code:

classNames(...list);

However, this approach makes code less readable in our opinion.

You could always wrap the function yourself to add array support 🤷

Will you accept feature requests?

Most likely not. If you prefer a different approach, consider using the original classnames library or other alternatives such as:

Alternatively, you can copy/paste the code itself (about 20 lines) and modify it to suit your needs.