smarte
v1.8.0
Published
Smarte is a lightweight utility library for managing conditional class names in React components.
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 smarteUsage
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
ClassListfrom thesmartelibrary. - Inside the component, we create an object where the keys represent class names, and the values represent conditions for adding those class names.
isSelectedis a boolean variable determined by themethods.isSelected(option)function, indicating whether an option is selected or not.- We use
ClassListto 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.
