Skip to content

Function: getContrastRatio()

ts
function getContrastRatio(a, b): number;

Computes the WCAG contrast ratio between two hex colors.

Parameters

ParameterType
astring
bstring

Returns

number

Example

ts
getContrastRatio('#ffffff', '#000000') // => 21

Since

1.0.0

Released under the MIT License.