@chalarangelo/combine-class-names
v1.0.0
Published
JS Utility for cleaner className template literals in React
Downloads
95
Maintainers
Readme
@chalarangelo/combine-class-names
JS Utility for cleaner className template literals in React
Usage
npm i @chalarangelo/combine-class-names
import combineClassNames from '@chalarangelo/combine-class-names';
const MyComponent = ({
isCool,
enabled = true,
active = false,
className
}) => (
<div className={combineClassNames`
my-component
${isCool ? 'cool' : 'not-cool'}
${enabled ? 'enabled' : '' }
${active ? 'active' : ''}
${className}
`}
/>
);
ReactDOM.render(
<MyComponent isCool enabled className='combined' />,
document.getElementById('root')
);
// Result: <div class="my-component cool enabled combined"/>