Skip to content
Advertisement

Dynamically change font color based on contrast

I’m looking to change the font color based on the color/contrast of what is behind it. i.e. if the color behind the text is white/light, the text will be black, if the color is dark/black, the font color will be white. Is this something that is achievable with mapbox? Or should I just go the route of outlining the text or something else.

Thanks!

Advertisement

Answer

There’s no mechanism I can think of that would let you achieve such a thing. The normal solution is to use text-halo-color to set an outline colour, so the label’s colour is readable against any background.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement