DEV Community

Marco Poletto
Marco Poletto

Posted on

How to automatically switch text color based on background's brightness

Here a quick example of how you can programmatically change text color, for example of a button, based on the element's background color.

The function take in account the brightness of the background and switch automatically text color.

Discussion (0)