Just sharing something I only just found out. More of a silly “Why didn’t I try it” kind of discovery. You can apply opacity to colors dynamically by adding the opacity code to a hex color.
Example: #002E45B2 - B2 is the opacity code
You can use any color picker like Pickr to get color codes with opacity.
Works dynamically so if you apply colors dynamically it works during runtime. Feel so dumb for not realizing this earlier.
Bubble recognizes more than just hex codes for color. For transparency, the rgba format is a bit more intuitive since the transparency (alpha) can be specified as a decimal fraction between 0 and 1. (Although the working example is no longer accessible, the following post and screenshot are still informative.)
Obviously, you don’t need to add all 100 levels, especially since the actual visual difference between 89% and 90%, for example, is almost imperceptible.
You can use multiples of 5% or 10%. This will be enough in most cases.
In this case, it’s much easier to reference an option set that is available throughout your app than to create expressions here and there across the app using the toolbox (possibly conditional ones, if you need different opacities in different scenarios).
Even if you use a reusable element or something similar, it will still be more laborious and less maintainable than the option set approach.
Code solves many problems, allows you to expand/abstract many things, but you know, it’s not always necessary.
Additionally, you can search your entire app using the App Search Tool to find all the places where a specific opacity from the option set is applied to (rarely necessary, but who knows?).