isCssColor
Commons
stable
Type guard that returns true when the input string is a valid CSS color value: a hex code, a functional notation (rgb, hsl, hwb, lab, lch, oklab, oklch, color), a CSS variable (var(--…)), or one of the 148 named CSS colors.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- colorstring | null | false
- The value to test. Falsy values (null, undefined, false, empty string) return false.
API
Valeur de retour
La valeur retournée par cet util.
- true when the string matches a recognised CSS color format; false for intent strings like "primary" or non-color values.
Usage
Exemples
Extraits de code prêts à coller.
Distinguish raw CSS colors from intent tokens