APCAcontrast
Color
stable
Compute the APCA (Accessible Perceptual Contrast Algorithm) contrast value between a text colour and a background colour. Returns a signed float in the range [-108, 106] — positive for dark text on light background, negative for light text on dark background.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- textrequiredTRGBA
- The foreground (text) colour as an RGBA object with r, g, b in [0, 255].
- backgroundrequiredTRGBA
- The background colour as an RGBA object with r, g, b in [0, 255].
API
Return value
The value returned by this util.
- Signed APCA contrast value. Absolute value >= 45 is the recommended minimum for body text.
Usage
Examples
Ready-to-paste usage snippets.
Black text on white background