isParsableColor
Commons
stable
Returns true when a string is a parsable CSS color value (hex, rgb, hsl, named…) but is NOT a CSS custom property reference (var(--…)). Combines the CSS color check with a var() exclusion.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- colorrequisstring
- The color string to test. CSS variables (var(--…)) are excluded even though they are syntactically valid CSS, because they cannot be parsed at runtime without resolving against the DOM.
API
Valeur de retour
La valeur retournée par cet util.
- true when the string is a parsable CSS color that can be processed immediately (no var() reference); false for intents, CSS variables, or non-color strings.
Usage
Exemples
Extraits de code prêts à coller.
Parsable vs non-parsable color strings