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

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

color
required
string
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

Return value

The value returned by this 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

Examples

Ready-to-paste usage snippets.

Parsable vs non-parsable color strings

typescript