CSS custom properties are variables, but they are not substituted when they appear as bare tokens in declaration values. For example, color:
--accent-color; is not interpreted as a variable lookup, so the declaration becomes invalid and is ignored.
This rule raises an issue when a custom property defined in the same source file is used as a value without the var() function.
Wrap the custom property reference in var() whenever it is used as a declaration value.
:root {
--accent-color: red;
}
a {
color: --accent-color; /* Noncompliant */
}
@property --accent-color {
syntax: "<color>";
inherits: false;
initial-value: red;
}
a {
color: --accent-color; /* Noncompliant */
}
:root {
--accent-color: red;
}
a {
color: var(--accent-color);
}
@property --accent-color {
syntax: "<color>";
inherits: false;
initial-value: red;
}
a {
color: var(--accent-color);
}
transition-property, are ignored:
@property --accent-color {
syntax: "<color>";
inherits: false;
initial-value: red;
}
a {
transition-property: --accent-color;
}