A lightweight utility for managing conditional classnames in React.
- 1kb gzip
pnpm add @teensy/cx -D
import cx from '@teensy/cx'
type CompProps = {
children: React.ReactNode;
}
const Component = ({ children }): CompProps => {
return(<div className={cx('first-class', hasProp ? 'conditional-class' : 'falsy class', { 'aria-invalid': ariaInvalid })}>)
}
Assuming hasProp
and ariaInvalid
evaluate to truthy
values, the result would be first-class conditional-class aria-invalid
.
MIT License
Copyright (c) 2024 Tom