Common mistakes
Nearly every class that doesn't work, written by a person or a model, is on this list.
Responsive
| Wrong |
Right |
Why |
p-32px @xs-p-16px |
@xs-p-16px @sm-p-32px |
A plain class beats every breakpoint class. |
d-none @lg-d-block |
@components[d-none] @lg-d-block |
The components layer sits below the breakpoints, so they can override it. |
@xs-x-col-12 @lg-x-col-6 |
@xs-x-col-12 @sm-x-col-12 @lg-x-col-6 |
@xs stops at 575px, so 576–991px would get nothing. |
xs-d-none, md-w-500px |
@xs-d-none, @md-w-500px |
Since 1.5.4 a breakpoint needs the @; the bare form compiles to nothing. Only dark- and light- still work without it. |
@2xl-… |
@xxl-… |
There is no 2xl. |
Values
| Wrong |
Right |
Why |
w(calc(100%-32px)) |
w(calc(100%_-_32px)) |
calc() needs spaces around + and -. |
c-red/50 |
c-red/0.5 |
Alpha is a decimal from 0 to 1. |
m-0_auto |
m-0-auto or margin(0_auto) |
_ is a space only inside a property function. |
m--x-gap:-8px |
m--x-gap:--8px |
Negative values, fallbacks included, use --. |
content-"" |
cont |
cont gives content: "". |
ff-Times_New_Roman--serif |
ff(Times_New_Roman,serif) |
Font lists use the function form. |
mw-640px for a maximum |
xw-640px |
mw is min-width, xw is max-width. |
o-.5 |
o-0.5 |
.5 works, but the leading zero is the documented form. |
c-red-i, c-red! |
c-red--imp |
!important is --imp (or --important). A single -i is a value code: d-i is display: inline. |
bgbm-multiply, wm-vertical-rl |
background-blend-mode-multiply, writing-mode-vertical-rl |
Since 1.5.4 rarely used properties have no alias. The full name always works. |
--sb-bg:red, --h-size:4px |
--x-sidebar-bg:red, --x-size:4px |
Short selector aliases own those prefixes. Start variables with --x-. |
Selectors
| Wrong |
Right |
Why |
--before--hover-c-red |
--hover--before-c-red |
The state goes before the pseudo-element. |
_.card-title-c-red |
_.(card-title)-c-red |
Class names with a dash go in parentheses. |
--not--first-child-… |
--not(--first-child)-… |
Selectors longer than one word go in parentheses. |
fs, c, bgc on their own |
fs-16px, c-red |
A property or alias with no value isn’t a class and compiles to nothing. |
anchor-name--x for a variable |
anchor-name--var--x |
In anchor and timeline properties --x is a name, not var(--x). |
[data-state='open']&d-block |
[data-state=open]&d-block |
Class names can’t contain quotes. |
Groups, exports and keyframes
| Wrong |
Right |
Why |
[_th[fw-600]] |
_th-fw-600, or a statement |
Groups can’t nest other elements. |
[x-stack,…]--as-row |
[d-flex,flex-direction-column,…]--as-row |
Exports take atomic classes only. |
[c-red,@dark-c-blue]--as-x |
[c-red]--as-x @dark[c-blue]--as-x |
Media scopes go before the group, not inside it. |
keyframes-fadeIn="…" |
keyframes-fade-in="…" |
HTML lower-cases attribute names. |
@from-[o-0] @to-[o-1] |
@0-[o-0] @100-[o-1] |
Keyframe stops are numbers. |
@0:50-[o-0] |
@[0,50][o-0] |
That’s the syntax for several stops. |
tf-rotate(180deg) on an element a library positions |
rotate-180deg |
An inline transform beats any class. rotate combines with it. |
Build setup
| Wrong |
Right |
Why |
className={'bgc-' + tone} |
className={TONES[tone]} with String('bgc-…') values |
The CLI only sees complete class names. |
String('…') in a project with lint auto-fix |
acss('…') and extractorFunction: 'acss' |
Auto-fix can delete String() and hide the classes from the CLI. |
<script src=…> in <head> without defer |
<script defer src=…> |
The browser script needs <body> to exist. |