hasAlpha

ColorPicker
stable

Detects whether a colour value carries an alpha channel. For strings it checks that the length exceeds 7 characters (8-digit hex or rgba/hsla). For objects it looks for an "a" or "alpha" own property. Returns false for falsy values.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

color
requis
any
A colour value in any format: hex string (#rrggbbaa), CSS string (rgba/hsla), or a colour object with an "a" or "alpha" property.

API

Valeur de retour

La valeur retournée par cet util.

true when an alpha channel is detected, false otherwise.

Usage

Exemples

Extraits de code prêts à coller.

String and object colour detection

typescript