isGradient

Commons
stable

Returns true when the value is a CSS gradient string (linear-gradient, radial-gradient, …), a preset gradient name, or a gradient object descriptor. Excludes intents, hex colors, and transparent.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

value
required
unknown
The raw value to test. Can be a string, object, or any other type. Strings are checked against CSS gradient syntax and preset names; objects are checked for a gradient descriptor shape.

API

Return value

The value returned by this util.

true when the value is recognised as a gradient (string or object form); false for intents, plain hex colors, transparent, null, or undefined.

Usage

Examples

Ready-to-paste usage snippets.

CSS gradient strings and non-gradient values

typescript