Core concepts
Class syntax
A JX class reads from left to right: variants, utility, value, importance.
Anatomy
md
:
hover
:
bg
:
blue
!
Variants
Breakpoints and states, stackable. Pseudo-elements always go at the end of the selector.
Utility
The property, abbreviated: bg, p, fs, cols, ring…
Value
A theme token, a keyword or an arbitrary value in brackets.
Important
Optional: adds !important to the declaration.
The general form is [variants:]utility[:value][!]. Only the utility is required:
flex.flex {
display: flex;
}
p:4
.p\:4 {
padding: 1rem;
}
md
:
p
:
8
@media (min-width: 768px) {
.md\:p\:8 {
padding: 2rem;
}
}
c
:
red
!
.c\:red\! {
color: #ef4444 !important;
}
Theme values
A plain value is looked up in the theme category tied to the utility: p:4
reads the spacing scale, c:teal-700
the palette, fs:lg
the font sizes.
p:4
.p\:4 {
padding: 1rem;
}
c:teal-700
.c\:teal-700 {
color: #0f766e;
}
fs:lg
.fs\:lg {
font-size: 1.125rem;
}
br:xl
.br\:xl {
border-radius: 0.75rem;
}
Arbitrary values
Inside brackets, the value is used as is. _
stands for a space, which is not allowed in a class name. Write \_
for a literal _; the
_ inside url(…)
are kept.
Note
An arbitrary value cannot contain ;,
{, },
< or !: it would be rejected for security reasons. See the Security page.
w
:
[calc(100%_-_2rem)]
.w\:\[calc\(100\%_-_2rem\)\] {
width: calc(100% - 2rem);
}
bg:abyss
cols
:
[200px_minmax(0,1fr)]
.cols\:\[200px_minmax\(0\,1fr\)\] {
grid-template-columns: 200px minmax(0,1fr);
}
Negative values
Rules that support it take a minus sign, before the class or before the value:
-
mt
:
2
.-mt\:2 {
margin-top: -0.5rem;
}
mt:-2
.mt\:-2 {
margin-top: -0.5rem;
}
-
ty
:
1
.-ty\:1 {
--jx-ty: -0.25rem;
translate: var(--jx-tx, 0) var(--jx-ty, 0);
}
@property --jx-ty {
syntax: "*";
inherits: false;
}
Importance
A trailing ! adds
!important to every declaration produced.
c
:
red
!
.c\:red\! {
color: #ef4444 !important;
}
md
:
hover
:
bg
:
blue
!
@media (min-width: 768px) {
.md\:hover\:bg\:blue\!:hover {
background-color: #3b82f6 !important;
}
}
Invalid classes
A class that breaks the syntax, or whose value does not exist, is rejected with a warning. It produces no CSS:
| Class | Result |
|---|---|
p:huge |
"p:huge" ignored: Invalid value "huge" for "p". Accepted values: 0, px, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10…; or an arbitrary value in brackets. |
c: |
Invalid class syntax: "c:" (empty segment (extra ":" or missing value)). |
hover: |
Invalid class syntax: "hover:" (empty segment (extra ":" or missing value)). |