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
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- colorrequiredany
- A colour value in any format: hex string (#rrggbbaa), CSS string (rgba/hsla), or a colour object with an "a" or "alpha" property.
API
Return value
The value returned by this util.
- true when an alpha channel is detected, false otherwise.
Usage
Examples
Ready-to-paste usage snippets.
String and object colour detection