color_contrast_checker: Color contrast

Description Usage Arguments Details Value Examples

View source: R/color_contrast_checker.R

Description

Get the color contrast of two colors

Usage

1
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'.

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.

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.

Examples

1
2
3
4
5
6
7
8
## Not run: 
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')

## End(Not run)

m-clark/visibly documentation built on Oct. 28, 2020, 5:33 p.m.