Description Usage Arguments Value Examples
Calculate the color contrast ratio of two provided colors. Intended as an visual accessibility aid when selecting a text color to place over a single- color background. The output value should be 4.5 or higher to ensure sufficient contrast and readability. This function is currently based on WCAG 2.1. See WCAG for more information about the calculation.
1 | cr_get_ratio(col_1, col_2, quiet = FALSE, view = FALSE)
|
col_1 |
Six-digit hex value preceded by '#', or a named color from
|
col_2 |
Six-digit hex value preceded by '#', or a named color from
|
quiet |
Whether to print warning when the ratio value is lower than 4.5. |
view |
Whether to plot a demonstration of col_1 text on a col_2
background, and vice versa, for visual inspection. Uses
|
A double.
1 | cr_get_ratio("#FFFFFF", "white")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.