Packages

clsx

2.1.1 · 23 Apr 2024MIT179.1M / weekRepositoryHomepagenpmAtom feed

Your version

2.1.0

29 Dec 2023Where it was published

2.1.1 is the newest release of 2.x.

In short

1 new

Release note

Features

  • Add new clsx/lite submodule for string-only usage: 1a49142

    This is a 140b version of clsx that is ideal for Tailwind and/or React contexts, which typically follow this clsx usage pattern:

    clsx('foo bar', props.maybe && 'conditional classes', props.className);

    Important: This clsx/lite module ignores all non-string arguments and is therefore not a 1:1 replacement for clsx itself!

    import { clsx } from 'clsx';
    import { clsx as lite } from 'clsx/lite';
    
    // strings-only usage is identical
    clsx('foo', null, 'bar', true && 'baz'); //=> "foo bar baz"
    lite('foo', null, 'bar', true && 'baz'); //=> "foo bar baz"
    
    // clsx/lite ignores all non-strings
    clsx('foo', { a: true, b: false, c: true }); //=> "foo a c"
    lite('foo', { a: true, b: false, c: true }); //=> "foo"

Full Changelog: v2.0.1...v2.1.0

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.