Skip to main content

readableColor

Returns a readable light/dark color based on the provided HEX value. User can provide custom light/dark values.

Parameters

  • hex string HEX color to change brightness

  • options Object? user provided object to override default colors

    • options.light string? light color
    • options.dark string? dark color

Examples

readableColor('#222001');
// => '#ffffff'

readableColor('#baebd8');
// => '#24292f'

readableColor('#261104', { light: '#fcf' });
// => '#fcf'

readableColor('#fbdbd7', { dark: '#000' });
// => '#A8646'

readableColor('#013735', { light: '#fcf', dark: '#000' });
// => '#fcf'

readableColor('#defbf7', { light: '#fcf', dark: '#000' });
// => '#000'

Returns string light/dark hex value.

Meta

  • version: 4.3.0