Skip to content

A lightweight JavaScript utility for conditionally joining class names together, taking up only 180 bytes.

Notifications You must be signed in to change notification settings

Bergamolt/classyfier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

classyfier

A lightweight JavaScript utility for conditionally joining class names together, taking up only 180 bytes.

Installation

npm install classyfier

import classyfier from 'classyfier';

const className = classyfier('button', { disabled: true }, ['active', 'selected']);
// className = 'button disabled active selected'

classyfier('foo', 'bar');
// Returns: 'foo bar'

classyfier('foo', null, undefined, 'bar');
// Returns: 'foo bar'

classyfier('foo', ['bar', 'baz']);
// Returns: 'foo bar baz'

classyfier('foo', { bar: true, baz: false });
// Returns: 'foo bar'

classyfier({ foo: true }, { bar: true }, { baz: false });
// Returns: 'foo bar'

classyfier([{ foo: true, bar: false }, 'baz']);
// Returns: 'foo baz'

classyfier(['foo', { bar: true, baz: false }, null, undefined]);
// Returns: 'foo bar'

About

A lightweight JavaScript utility for conditionally joining class names together, taking up only 180 bytes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published