Skip to content
scroll to zoom · drag to pan

bestTextContrast

function bestTextContrast(hex): {
color: "#000000" | "#FFFFFF";
passesAA: boolean;
passesAALarge: boolean;
ratio: number;
};

Defined in: packages/asset-client/src/palette.ts:145

Same choice as the recommended text colour, but it also returns the ratio it achieved and whether that passes AA — so a caller can decide with the number in front of them instead of assuming it was enough.

Parameter Type
hex string
{
color: "#000000" | "#FFFFFF";
passesAA: boolean;
passesAALarge: boolean;
ratio: number;
}
color: "#000000" | "#FFFFFF";
passesAA: boolean;
passesAALarge: boolean;
ratio: number;