classnamesx
v1.0.4
Published
An alternative to the popular classnames package, written in just 11 lines of (es6) javascript.
Downloads
6
Readme
This package serves as an simple alternate to the popular classnames package, written in just 10 lines of (es6) javascript.
Example usage:
import classNames from "classnamesx";
classNames("foo", "bar"); // "foo bar"
classNames(["foo", "bar"]); // "foo bar"
classNames("foo", { bar: true }); // "foo bar"
classNames({ foo: true }, { bar: true }); // "foo bar"
classNames({ foo: true, bar: true }); // "foo bar"
classNames({ foo: true, bar: true, baz: false }); // "foo bar"
classNames({ foo: true }, ["bar", { baz: true }]); // "foo bar baz"
// in a React app...
export default function MyComponent({ isActive }) {
return <div className={classNames({ active: isActive })}>Hello, world!</div>;
}