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.

Top comments (0)

We want your help! Become a Tag Moderator.
Check out this survey and help us moderate our community by becoming a tag moderator here at DEV.