Can you define certain Names to share conditional features

Keeping the code DRY is important to me. I’m trying to figure out, if I have various elements on a page that I want to apply the SAME conditionals to (e.g., maybe there’s an image and block of text that both are only visible to users that are logged in), BUT the elements are not close enough together where I can group them under a common Group, is there another way to target both of them with a single conditional statement?

Right now I have both of them with a Conditional statement, but that’s a bit brittle…

That is a single conditional statement “current user is logged in”

Do you mean not having to copy the condition from the text to the image?

Yes correct, so right now the Text element has a condition, and the Image element has a condition.

This means that if I were to ever want to change that conditional statement, I’d have to change it on both elements.

Simply no. Bubble does not have anything like that right now.

Hi @james46 create a variable group (small sized and not necessarily visible) make the group type (yes/no), paste your condition in the group. Let your image and text have a condition referencing the variable group. (image condition can be - make visible - if variable group yes/no is yes)

This topic was automatically closed after 70 days. New replies are no longer allowed.