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

klassik

v1.0.1

Published

A utility function for joining CSS class names.

Readme

Klassik

A tiny and fast utility for conditionally joining class names.

Installation

npm install klassik
# or
yarn add klassik
# or
pnpm add klassik

Usage

Import kl and pass any number of string arguments. Falsy values (like false, null, undefined) are automatically ignored. Use standard JavaScript expressions for conditional logic.

import kl from 'klassik';
// or: import { kl } from "klassik";

// Basic joining
kl('class1', 'class2');
// => "class1 class2"

// Joins arguments with existing spaces
kl('class1 class2', 'class3', 'class4 class5');
// => "class1 class2 class3 class4 class5"

// Conditional classes using &&
kl('class1', true && 'class2');
// => "class1 class2"

// Falsy conditions are ignored
kl(false && 'class1', 'class2');
// => "class2"

// Conditional classes using ternary operator
kl(true ? 'class1' : 'class2');
// => "class1"

// Combine static and conditional
kl('class1', false ? 'class2' : 'class3');
// => "class1 class3"

// Complex example combining multiple conditions
const isPrimary = true;
const isLarge = false;
kl('flex', isPrimary ? 'bg-primary-100' : 'bg-secondary-100', isLarge ? 'm-4 p-4' : 'm-2 p-2');
// => "flex bg-primary-100 m-2 p-2"

Highlights

  • Tiny: Extremely lightweight with a minimal footprint.
  • Fast: Simple logic leads to great performance.
  • ESM & CJS: Supports both ES Modules and CommonJS.
  • Zero Dependencies: No external dependencies needed.
  • Typed: Fully typed with TypeScript.

Migrating to Klassik

If you are migrating from libraries like classnames or clsx:

  1. Change your import statement:

    - import classnames from 'classnames';
    + import kl from 'klassik';
    
    // or
    - import clsx from 'clsx';
    + import kl from 'klassik';
  2. Convert object arguments: klassik only accepts string arguments (it filters out non-strings/falsy values). Convert any object syntax to use standard JavaScript conditional expressions (&& or ternary ? :).

    - classnames({ 'class-1': cond1, 'class-2': cond2 });
    + kl(cond1 && 'class-1', cond2 && 'class-2')
    
    // Example with ternary
    - clsx({ 'class-active': isActive, 'class-inactive': !isActive });
    + kl(isActive ? 'class-active' : 'class-inactive')