Get the color contrast of two colors

color_contrast_checker(foreground, background = "#FFFFFF")

Arguments

foreground

Character string. An R color or color as hex.

background

Character string. An R color or color as hex. Default is white/'#FFFFFF'.

Value

If you have jsonlite, it will return a data frame of the ratio and which standards are passed. Otherwise you get the same information but as a character vector.

Details

This uses the api at webaim.org to determine the contrast ratio of the foreground color to the background color. This is useful to ensure chosen colors meet web standards for accessibility.

Examples

if (FALSE) { library(visibly) color_contrast_checker(foreground = 'red', background = 'papayawhip') # standard blue is not good for contrasting links from other text color_contrast_checker(foreground = '#000080', background = 'black') }