Skip to content

Teensy tiny utility for conditionally managing classnames in JSX / React

License

Notifications You must be signed in to change notification settings

tbusillo/teensy-cx

Repository files navigation


Teensy Tiny Cx

A lightweight utility for managing conditional classnames in React.


CI status


Features

  • 1kb gzip

Installation

pnpm add @teensy/cx -D

Usage

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.

License

MIT License

Copyright (c) 2024 Tom

About

Teensy tiny utility for conditionally managing classnames in JSX / React

Resources

License

Stars

Watchers

Forks

Packages

No packages published