# react-auto-classnames

> JSX runtime for applying `clsx()` automatically

Latest version **1.0.2** (published 2022-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-auto-classnames
pnpm add react-auto-classnames
yarn add react-auto-classnames
bun add react-auto-classnames
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-09-30 |
| First published | 2021-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | meowtec |
| Maintainers | meowtec |
| Keywords | react, classnames, clsx, jsx-runtime |

## Links

- npm: https://www.npmjs.com/package/react-auto-classnames
- Homepage: https://github.com/meowtec/react-auto-classnames
- npm.io page: https://npm.io/package/react-auto-classnames

## Dependencies (1)

- [clsx](https://npm.io/package/clsx.md) ^1.1.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-09-30
- 1.0.1 — 2021-10-12
- 1.0.0 — 2021-10-11

## README

# react-auto-classnames

JSX runtime for applying `clsx()` to `className` prop automatically.

NOT a babel plugin.

## Installation

```
npm i react-auto-classnames
```

## Usage

If you use TypeScript, edit your `tsconfig.json` like:

```js
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "react-auto-classnames",
  }
}
```

If you use `@babel/preset-react` to transform jsx:

```js
// .babelrc / babel.config.json
{
  "presets": [
    [
      "@babel/preset-react",
      {
        "runtime": "automatic",
        "importSource": "react-auto-classnames"
      }
    ]
  ]
}

```

If you use esbuild (take *vite* for example):

```js
{
  esbuild: {
    jsxFactory: 'createElement',
    jsxFragment: 'Fragment',
    jsxInject: 'import { createElement, Fragment } from \'react-auto-classnames\'',
  },
}
```

Then you can write React code like this:

```js
function App() {
  return (
    <div className={['class-a', 'class-b', {
      'class-disabled': disabled,
    }]}>
  )
}
```

[clsx](https://github.com/lukeed/clsx) will be used to handle the `className` prop.

---
_Source: https://npm.io/package/react-auto-classnames · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
