getLuma
Commons
stable
Returns the perceptual luminance (Y channel in CIE XYZ space) of a color. Used internally by the contrast checker to decide foreground colour on coloured surfaces.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- colorrequiredTColorType
- The color to evaluate. Accepts any format supported by parseColor (hex, rgb, hsl, named CSS colour).
API
Return value
The value returned by this util.
- The relative luminance as a number between 0 (black) and 1 (white).
Usage
Examples
Ready-to-paste usage snippets.
Check luminance to choose a foreground colour