Change color when pressing button

Can you make a button change colors when you press it? That way it looks like the user has picked that “preference” from a list of options.

Hopefully you understand. Thanks :slight_smile:

It’s not possible directly but there’s a workaround for it.

Add 2 buttons: one above the other touching at the borders.

Have a boolean flag in your collection. Show the first button when the boolean is false using visibility conditions.

When the button is clicked, update the boolean to true and show the second button.

The reason you need to put the buttons one below the other touching at the borders is, when the top one is invisible, second one moves up to take its position. That way it feels like only one button.

Hope this helps

1 Like

Thanks, Bhanu. I am just wondering how to add a boolean flag and what exactly it is.

Thank you,

Alvaro

Hello Bhanu,

How do you add the said answer to a project?

Add 2 buttons: one above the other touching at the borders.

Have a boolean flag in your collection. Show the first button when the boolean is false using visibility conditions.

When the button is clicked, update the boolean to true and show the second button.

Can you add an example?

That’s a crafty workaround. Nice!

@NCMobile not sure I understand you ask, can you please elaborate?

If I understand you right, you want the button color to change when it is clicked, which means you want to indicate in you database that a particular item is selected upon clicking the button.

Boolean flag is True/False field in your DB. When the button is clicked, you’re updating the field to True to indicate the item has been selected, and when you click the second button you’re turning the field to false indicating the item is unselected.

Hope it’s clearer now.

How do you have a boolean flag in your collection. Show the first button when the boolean is false using visibility conditions. How do you do this. Can you show an example?

Image 1: shows the field is true/false
Image 2: shows the setup using conditional visibility.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.