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

polettoweb

Marco Poletto

Posted on June 26, 2019

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.

💖 💪 🙅 🚩
polettoweb
Marco Poletto

Posted on June 26, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related