Just wanted to share something that might not be widely known…
Most of us have typed or copied/pasted hex codes into color fields in the Bubble editor. But did you know that most color fields also accept dynamic expressions which evaluate to a text (string) representing a color?
The text expression can be in one of at least 3 formats - hex codes, rgb, or rgba. Following is the color yellow in each format:
- #FFFF00
- rgb(255,255,0)
- rgba(255,255,0,0)
The “a” stands for “alpha channel”. It represents transparency and is a value from 0 to 1. Following is an example of what this capability enables. Just play with the sliders:
Behind the scenes, the color value is simply being set to the following dynamic expression…
This opens the possibility of controlling the color and/or transparency of UI elements based on numeric data from your app. Pretty cool.