Rate

The rate API rates colors based on certain properties and features.

rateContrast

The rateContrast method calculates the contrast ratio of two colors based on WCAG guidelines. It also returns whether the contrast ratio passes or fails the WCAG criteria for levels AA and AAA.

Syntax

rateContrast(colors)

Parameters

colors: A string of objects of type Rgb. It has to have 2 colors.

Return value

An object of type WCAGContrast, with all the needed info to know about contrast guidelines.

Examples

rateContrast(['#002719', '#c49c1a'])
// Expected output: {
  contrastValue: 6.2,
  AA: {
    smallText: true,
    largeText: true,
    uiComponent: true
  },
  AAA: {
    smallText: false,
    largeText: true,
    uiComponent: true
  }
}
If you notice an error in the documentation, please edit the page to fix it.