Skip to content

A small dependency-free utility to combine css classes written in TypeScript

License

Notifications You must be signed in to change notification settings

garystorey/cssclass

Repository files navigation

cssclass

A small dependency-free utility to combine css classes written in TypeScript.

Version Size License

Leywords

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.

About

A small dependency-free utility to combine css classes written in TypeScript

Topics

Resources

License

Stars

Watchers

Forks