@skchr/color
    Preparing search index...

    Function contrast

    • Gets the contrast between the passed in colors.

      Swapping color a and b in the parameter list doesn't change the resulting value. The maximum value is 21 (or the contrast between black and white).

      Parameters

      • a: ColorToken = "white"

        First color to query. The default is white.

      • b: ColorToken = "black"

        The color to compare against. The default is black.

      Returns number

      • The contrast ratio between the two colors.
      import { contrast } from '@skchr/color'

      console.log(contrast("blue", "red"));
      // 21