clnames is a NPM Package to concat simple and conditional classnames in your JavaScript project.
# In your terminal, enter command:
npm install clnamesimport clnames from "clnames";
clnames(...classes);Arguments classes must be a string or an object.
See example with React, below:
import { useState } from "react";
import clnames from "clnames";
const App = () => {
const [color, setColor] = useState("blue");
//...
return (
<div className="App">
<div
className={clnames(
"font-bold",
{
"text-blue-500": color === "blue",
"text-red-300": color === "red",
} /*...*/
)}
>
Hello, I'm {color}
</div>
</div>
);
};
export default App;If you are interested in this project and want to improve it, fix errors or bugs, you're welcome to contribute.
The MIT License (MIT).
Note
Please see License File for more information.