ts-clsx
TypeScript icon, indicating that this package has built-in type declarations

2.4.1 • Public • Published

ts-clsx

npm version npm downloads coverage bundle License

Rewrite clsx in TypeScript, but no default export.

Install

ni ts-clsx

Usage

import { clsx } from 'ts-clsx'

clsx('foo', [1 && 'bar', { baz: false, bat: null }, ['hello', ['world']]], 'cya')
// => 'foo bar hello world cya'
// Lite version, accepts only string arguments
import { clsx } from 'ts-clsx/lite'

clsx('hello', true && 'foo', false && 'bar', { foo: true }, ['hello', ['world']])
// => "hello foo"

Tailwind Support

  1. VS Code + Tailwind Intellisense Extension
  2. Add the following to your settings.json
{
  "tailwindCSS.experimental.classRegex": [
    ["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
  ]
}

License

MIT License © 2024-PRESENT Mancuoj

Package Sidebar

Install

npm i ts-clsx

Weekly Downloads

3

Version

2.4.1

License

MIT

Unpacked Size

9 kB

Total Files

19

Last publish

Collaborators

  • mancuoj