font-size
The use-design-tokens rule checks that CSS font-size declarations use
design token variables instead of hardcoded values. This ensures consistent
font-size usage across the application and makes it easier to maintain design
system consistency.
Examples of incorrect code for this rule
.custom-text {
font-size: 12px;
}
.heading {
font-size: 1rem;
}
.small-text {
font-size: 0.867rem;
}
.large-text {
font-size: 1.2em;
}
.percentage-text {
font-size: 100%;
}
.point-text {
font-size: 16pt;
}
Examples of correct token usage for this rule
.custom-text {
font-size: var(--font-size-root);
}
.small-text {
font-size: var(--font-size-small);
}
.large-text {
font-size: var(--font-size-large);
}
.xlarge-text {
font-size: var(--font-size-xlarge);
}
.xxlarge-text {
font-size: var(--font-size-xxlarge);
}
.xxxlarge-text {
font-size: var(--font-size-xxxlarge);
}
.heading-medium {
font-size: var(--font-size-heading-medium);
}
.heading-large {
font-size: var(--font-size-heading-large);
}
.heading-xlarge {
font-size: var(--font-size-heading-xlarge);
}
/* Local CSS variables that reference valid font-size tokens are allowed */
:root {
--custom-font-size: var(--font-size-small);
}
.custom-text {
font-size: var(--custom-font-size);
}
.custom-text {
font-size: var(--custom-font-size, var(--font-size-small));
}
The rule also allows the non-token values listed for Font size in the checked properties.