You don't need several text elements to display different texts under different conditions. You can use conditional statements to change the text. This will make your app simpler to organise and manage.
Creating the conditional statements
Let's say you have a dropdown where I can select a product. You want a text element that tells you whether the product is 'For Sale'. But, the product status is stored in a Yes/No field type, so you cannot display the product status using dynamic data.
How you can do it is to create two conditional statements. One to show a text if the 'For Sale' field is Yes and another if it is No.
- You begin by creating a text element and styling it how you want.
- You then add two conditional statements to the text.
- If the Dropdown value's For Sale is "yes" > Select a property to change when true > Text. Now you can enter whatever text you want to be displayed.
- If the value is "no", you can show a different value.
And this is a generic example. You can also change the font, colour, alignment and a host of different properties of the text element depending on the conditions.
Let's take another example. You want to show a text based on the custom state value.
We can create a simple toggle element to change the custom state value. Then we can use the custom state's value to show text based on the current value of the custom state.
- I created a custom state at the page level called "Active". The value of the custom state depends upon the toggle element.
- If the toggle is checked, the value is "Yes". Else it is "No".
- I created another text element and put conditions similar to the earlier example.
The main takeaway is that just like the other features of Bubble, the text element is also powerful and can be customised for our needs. The only limiting factor is our creativity.