React classnames made Perfect
A utility for generating class names in React. This library is made to be Perfect for me. As my css proclivities change this library will evolve with them in hopes of truly living up to it's name.
perfect-classnames
generates BEM style class names from props.
import { createFromProps } from 'perfect-classnames';
const fromProps = createFromProps(
'FlexComponent',
{
direction: {
prepend: true,
values: ['row', 'column'],
},
size: ['small', 'medium', 'large'],
wrap: true,
}
);
const FlexComponent = (props) => {
let classes = fromProps(props);
...
};
<FlexComponent direction="row" size="small" wrap />
// ['FlexComponent', 'FlexComponent--directionRow', 'FlexComponent--medium', 'FlexComponent--wrap']