Skip to main content

getOppositeColor()

function getOppositeColor(
hexCode,
darkColor,
lightColor): string

Get the opposite color for text based on the background color

Parameters

ParameterTypeDefault value
hexCodestringundefined
darkColorstring'#000000'
lightColorstring'#FFFFFF'

Returns

string

Opposite color for text in hex format

Throws

If the provided hexCode is invalid

Example

const oppositeColor = getOppositeColor({ hexCode: "#FFFFFF" });
console.log(oppositeColor); // Outputs: "#000000"

Defined in

hacks/hacks.ts:20