Skip to content
Join CSS class names with test
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
test
.gitignore
.npmignore
.publishrc
build.js
package-lock.json
package.json
readme.md
src.js

readme.md

cssJoin

Examples

Simple joining 2 class names.

cssJoin("button", "buttonPrimary");
// "button buttonPrimary"

Usually I'm using class names in an obj.

cssJoin(css.btn, css.primary);
// "button buttonPrimary"

If a class name is actually an array, then the pattern is [test, trueClass, falseClass]

cssJoin(css.btn, [ btnType === "primary", css.primary ])
// "button buttonPrimary" or "button"

cssJoin(css.btn, [ btnType === "primary", css.primary, css.secondary ])
// "button buttonPrimary" or "button buttonSecondary"

An example with Mithril

const component = {
    view : (vnode) =>
        m("div", {
            class : cssJoin(btnCss.btn, [ vnode.state.selected, css.selected ])
        })
};
You can’t perform that action at this time.