cssclass
A small dependency-free utility to combine css classes written in TypeScript.
Installation
You can install either with npm
or yarn
:
npm install @garystorey/cssclass
yarn add @garystorey/cssclass
Usage
Example in JavaScript:
import cssclass from '@garystorey/cssclass'
const value = 1
const classes = cssclass(`default`, {
notadded: value === 0,
added: value === 1,
})
console.log(classes)
// "default added"
Since cssclass
is written in TypeScript, it includes its own types.
import { cssclass, CSSClassObject } from '@garystorey/cssclass'
const classObject: CSSClassObject = {
notadded: value === 0,
added: value === 1,
}
const value: number = 1
const classes = cssclass('default', classObject)
console.log(classes)
// "default added"
You can see it in action on this CodeSandbox.