smarte
v1.8.0
Published
Smarte is a lightweight utility library for managing conditional class names in React components.
Downloads
11
Readme
Smarte
Smarte is a lightweight utility library for managing conditional class names in React components.
Installation
You can install Smarte via npm:
npm install smarte
Usage
Import
import ClassList from 'smarte';
Example
Here's an example of how you can use Smarte to conditionally add class names in a React component:
import React from 'react';
import ClassList from 'smarte';
const MyComponent = () => {
// Assuming 'methods.isSelected' is a function that determines if an option is selected
const isSelected = methods.isSelected(option);
return (
<div className={ClassList({
"dropdownRow": true,
"industryListRow": true,
"Selected": isSelected
})}>
Your Content
</div>
);
};
export default MyComponent;
In the above code:
- We import
ClassList
from thesmarte
library. - Inside the component, we create an object where the keys represent class names, and the values represent conditions for adding those class names.
isSelected
is a boolean variable determined by themethods.isSelected(option)
function, indicating whether an option is selected or not.- We use
ClassList
to conditionally apply class names based on the conditions specified in the object.
License
This project is licensed under the MIT License - see the LICENSE file for details.