Gathering detailed insights and metrics for babel-plugin-transform-jsx-classnames
Gathering detailed insights and metrics for babel-plugin-transform-jsx-classnames
Gathering detailed insights and metrics for babel-plugin-transform-jsx-classnames
Gathering detailed insights and metrics for babel-plugin-transform-jsx-classnames
babel-plugin-transform-jsx-class
Support classnames with directive.
@alita/babel-transform-jsx-class
Support classnames with directive.
babel-plugin-transform-tailwind-to-props
Transform Tailwind-like classes to JSX props and objects
@maccman/babel-plugin-transform-jsx-classnames
className and styleName on steroids
className and styleName on steroids
npm install babel-plugin-transform-jsx-classnames
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5 Stars
8 Commits
1 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Sep 14, 2023
Latest Version
1.2.2
Package Id
babel-plugin-transform-jsx-classnames@1.2.2
Unpacked Size
366.06 kB
Size
85.23 kB
File Count
24
NPM Version
9.5.1
Node Version
18.16.0
Published on
Jun 21, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
className and styleName on steroids 💪
Allow you to write jsx classNames in a simpler way, without having to worry about importing a helper (like clsx or classnames). className
or styleName
attributes take any number of arguments which can be a string, an array or an object (if the value associated with a given key is falsy, that key won't be included in the output). See examples
When babel-plugin-transform-jsx-classnames cannot resolve className
/ styleName
during compilation, it imports a helper function (read build time resolution). Therefore, you must install babel-plugin-react-css-modules as a direct dependency of the project.
1$ npm install babel-plugin-transform-jsx-classnames --save
1{ 2 plugins: [ 3 ['transform-jsx-classnames', { 4 // default options 5 dedupe: false, 6 attributes: ['className', 'styleName'] 7 }] 8 ] 9}
Note: ⚠️ If you're using
babel-plugin-react-css-modules
, ensure you're addingtransform-jsx-classnames
before
The plugin will try to resolve the className
/ styleName
during the compilation (className={"foo", { active: true }}
) and fallback to runtime if not possible (className={_cx("bar", { disabled: props.disabled })}
- a tiny helper (256B minified) will be included automatically.
The runtime helper is similar to the clsx package. See examples.
Dedupe behaves like the classname dedupe version. Way faster though. Its speed is similar to classnames
in no dedupe version.
The only difference you'll find will be with full numeric classNames: output will always spit numbers first (ex: className={"a", 12}
=> className="12 a"
). It shouldn't be a big deal though, as using numeric values for classNames is pretty rare and order only matters in a very few specific cases.
See benchmark dir.
1<div className={"foo", "bar"}> 2→ <div className="foo bar"></div> 3 4<div className={'foo', { bar: true }}> 5→ <div className="foo bar"></div> 6 7<div className={{ 'foo-bar': true }}> 8→ <div className="foo-bar"></div> 9 10<div className={{ 'foo-bar': false }}> 11→ <div className=""></div> 12 13<div className={{ foo: true }, { bar: true }, ["foobar", "duck"]}> 14→ <div className="foo bar foobar duck"></div> 15 16<div className={'foo', { bar: true, duck: false }, 'baz', { quux: true }}> 17→ <div className="foo bar baz quux"></div> 18 19<!-- styleName --> 20<div styleName={"foo", "bar"}> 21→ <div styleName="foo bar"></div> 22 23<!-- Dedupe --> 24<div className={'foo foo', 'bar', { bar: true, foo: false }}> 25→ <div className="bar"></div> 26 27<!-- No change --> 28<div className={props.active ? "foo" : "bar"}> 29→ <div className={props.active ? "foo" : "bar"}></div>
When className
/ styleName
can't be resolved at compilation.
1<div className={"foo", { active: props.active }}> 2→ <div className={_cx("foo", { active: props.active })}></div> 3 4<div className={{ foo: true, [`btn-${props.type}`]: true }}> 5→ <div className={_cx({ foo: true, [`btn-${props.type}`]: true })}></div> 6 7<div className={"foo", props.active && getClassName()}> 8→ <div className={_cx("foo", props.active && getClassName())}></div>
You like this package?
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/8 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
88 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More