Skip to content

babel plugin for automatically adding `classnames()` to `className` attribute.

License

Notifications You must be signed in to change notification settings

knoopx/babel-plugin-jsx-classnames

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-jsx-classnames

transform

<div className={arrayOrObjectExpr}></div>

to

<div className={classNames(arrayOrObjectExpr)}></div>

why

with react

<button className={`${active ? 'btn-active' : ''} ${disabled ? 'btn-disabled' : ''}`}>
</button>
<button
  className={classNames({
    'btn-active': active,
    'btn-disabled': disabled,
  })}>
</button>

with babel-plugin-jsx-classnames

<button
  className={{
    'btn-active': active,
    'btn-disabled': disabled,
  }}>
</button>

usage

npm i babel-plugin-jsx-classnames --save-dev
{
  "presets": [
    "env",
    "react"
  ],
  "plugins": [
    ...
    "jsx-classnames"
  ]
}

About

babel plugin for automatically adding `classnames()` to `className` attribute.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%