We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardize how we code conditional classes using the classnames library
Some code examples of what the difference will be:
// Setup const isUndefined = undefined; const isFalse = false; const isZero = 0; const isNull = null; let className; let styles = { header: "header" };
<div className={`${styles.header} ${className}`}/> translates to <div class="class undefined" />
<div className={`${styles.header} ${className}`}/>
<div class="class undefined" />
<div className={classNames(styles.header, className)}/> translates to <div class="class" />
<div className={classNames(styles.header, className)}/>
<div class="class" />
<div className={[ "class", isFalse && "isFalse", isZero && "isZero", isNull && "isNull", isUndefined && "isUndefined" ].join(" ")} />
Translates to <div class="class false 0 " />
<div class="class false 0 " />
<div className={classNames( "class", isFalse && "isFalse", isZero && "isZero", isNull && "isNull", isUndefined && "isUndefined" )} />
Translates to <div class="class" />
The text was updated successfully, but these errors were encountered:
oskarleonard
No branches or pull requests
Description
Standardize how we code conditional classes using the classnames library
Motivation
Additional Information
Some code examples of what the difference will be:
String literals
<div className={`${styles.header} ${className}`}/>
translates to<div class="class undefined" />
Classnames lib
<div className={classNames(styles.header, className)}/>
translates to<div class="class" />
[].join(" ")
Translates to
<div class="class false 0 " />
Classnames lib
Translates to
<div class="class" />
The text was updated successfully, but these errors were encountered: