Skip to content

Function: getReadableTextColor()

ts
function getReadableTextColor(background): string;

Returns '#000000' or '#ffffff' — whichever is more readable on top of the given background hex color.

Parameters

ParameterType
backgroundstring

Returns

string

Example

ts
getReadableTextColor('#336699') // => '#ffffff'
getReadableTextColor('#ffff00') // => '#000000'

Since

1.0.0

Released under the MIT License.