Raxol.Style.Colors.Accessibility.Suggester (Raxol v2.6.0)

View Source

Suggests accessible color alternatives based on WCAG contrast requirements.

Extracted from Raxol.Style.Colors.Accessibility.

Summary

Functions

Finds an accessible color pair (foreground/background) based on a base color and WCAG level.

Returns the optimal text color (black or white hex) for a given background.

Suggests a color with good contrast (at least AA) to the base color.

Suggests an appropriate text color (black or white) for a given background.

Functions

accessible_color_pair(base_color, level \\ :aa)

Finds an accessible color pair (foreground/background) based on a base color and WCAG level.

darken_until_contrast(color, background, target_ratio)

get_optimal_text_color(background)

Returns the optimal text color (black or white hex) for a given background.

lighten_until_contrast(color, background, target_ratio)

suggest_accessible_color(color, background)

suggest_contrast_color(color)

Suggests a color with good contrast (at least AA) to the base color.

Prioritizes complementary color, then black/white.

suggest_text_color(background)

Suggests an appropriate text color (black or white) for a given background.

Ensures minimum AA contrast.