Skip to content

colorLegible

Darkens a color so that it will appear legible on a white background.

Each pale input is darkened (its lightness capped, saturation clamped) to a deeper shade of the same hue that stays readable as text on a white background.

import {colorLegible} from "@d3plus/color";

colorLegible("#aaddff");
colorLegible("#ffeb3b");
colorLegible("#c8e6c9");
colorLegible("#ff8a80");
colorLegible("#e0e0e0");

Parameters

import {colorLegible} from "@d3plus/color";
crequiredstring

A valid CSS color string.