demo · v136
Type-agnostic var()
Edit a registered <color> variable and a fallback expression. Pre-136, only colours were valid fallbacks; from 136, any string parses and only resolves against the property's own grammar.
actually used (var resolves)
resolved colour
--accent has a value, fallback is unused
fallback path (--accent unset)
fallback colour
…
the code
@property --accent {
syntax: "<color>";
inherits: false;
initial-value: rebeccapurple;
}
.button {
/* Pre-136: fallback "currentColor" rejected — not a <color> literal.
136+: fallback parses as any value, validated against the property
being assigned (color: here), so currentColor is fine. */
color: var(--accent, currentColor);
}
see also
- Type-agnostic var() fallback — feature index
- ChromeStatus entry
- CSS Custom Properties spec