0.3.1 • Published 9 months ago

jcls v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

CSS class joiner/remover utility

Install

yarn add jcls
# or
npm install -S jcls
import jcls, {rcls} from 'jcls'
// or
const jcls = require('jcls')
const {rcls} = require('jcls')

API

Exported methods

export default function jcls(...classNames: readonly any[]): string;
export declare const rcls: (classNames: string, ...toRemove: readonly any[]) => string;
  • jcls(...classNames): Join classes into a single string.

    Falsy parameters are ignored. Other values are joined.

  • rcls(classNames, ...toRemove): remove classes from an existing class string.

    toRemove can contain string, boolean, RegExp, or function. Falsy parameters from toRemove are ignored.

Sample usages

jcls(
	styles.container,
    isDisabled && styles.disabled,
    '', // ignored
)
jcls('mb-2 p-3', styles.button)
rcls('mb-2 p-3 flex', 'p-3', 'flex') // note: toRemove must include class name separatedly
rcls('mb-2 p-3 flex', /p-.*/, /p?-.*/)
0.3.0

9 months ago

0.2.7

11 months ago

0.2.6

11 months ago

0.3.1

9 months ago

0.2.1

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.1.0

2 years ago

0.1.2

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.0.1

3 years ago