Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
classnames.macro
Advanced tools
Conditionally join CSS class names at build time in Babel.
The main goal of this package is to provide convenient API for CSS class names manipulation with the smallest performance hit.
Use with caution. The package is aiming to implement as many of classnames
features as it is possible for a macro. classnames.macro
is actively used as it is being developed but is not guaranteed to be problem-free.
Install and configure babel-plugin-macros
if you haven’t yet. Then use classnames.macro
almost the same way you use classnames
.
Given the following input:
import classNames from "classnames.macro"
function getClassName(options) {
return classNames("block", options.dark && ["bg-black", "text-white"], {
"font-bold": options.variant === "head",
"text-sm": options.variant === "footnote",
})
}
Babel will produce the following output:
function getClassName(options) {
return (
"block" +
((options.dark ? " bg-black text-white" : "") +
((options.variant === "head" ? " font-bold" : "") +
(options.variant === "footnote" ? " text-sm" : "")))
)
}
MIT
FAQs
Babel Macro for conditionally joining CSS class names together
The npm package classnames.macro receives a total of 28 weekly downloads. As such, classnames.macro popularity was classified as not popular.
We found that classnames.macro demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.