Toggle Yes/No Custom State

Would be a big time saver to have an action that toggles a Yes/No Custom State to on/off


Second that.

1 Like

Yes would certainly be handy, it could fit nicely within the Workflow > Visual > Toggle. Then when selecting the element to Toggle, if the element has a state assigned to it, a checkbox appears stating if you want to enable toggle the yes/no state…

Agree this would be handy, but to toggle any Boolean (yes/no) just evaluate:

BooleanValue is “no”

This returns “yes” if the thing is “no”. It returns “no” if the thing is “yes”. So, toggle.

(Though I do hate that syntax and would prefer an operator for Booleans like :inverse or :not.)


Yeah I agree it could be a pretty handy tool!

Instead of boolean use a number n with initial state 0 or 1 depending if you want it to start as false or true. Then every time you want it toggled set state n = n + 1

When you want to evaluate the Boolean just use modulo 2 function on n

So condition n mod 2 is ‘1’

The result depending on n will be

n = 0 -> no
n = 1 -> yes
n = 2 -> no
n = 3 -> yes

And so on…

This is you Boolean toggle.


@JonL While your suggestion works, you CAN just toggle the Boolean! See my note a couple of replies above. A Boolean toggle in Bubble is this (posted a couple replies above):

So you Set State > select the custom state that is a yes/no and set it like this:

This flip-flops the state of SomeBoolean from no to yes and vice-versa.


Nice find!

Sorry didn’t read your post! I will look for my Boolean numeric toggles and swap them for yours. Much easier to maintain and to read :slight_smile:

I wished people used more often the Mark as Solution feature for Discouse :slight_smile:

1 Like

This has the added advantage of being able to use Conditions much easier as well. For example, if the thing that triggers the toggle is a button, you can indicate its state by modifying the text on the button in the button’s Conditional tab, like:

When SomeBoolean is “no” > Text is “Off”
When SomeBoolean is “yes” > Text is “On”


Well, the original question is several months old and the OP probably isn’t paying attention to this thread any longer? :thinking:

(The other thing I’d say about this, as I’ve pointed out in other threads on the same subject: I felt like I was going crazy when I couldn’t originally figure out where the “not” operator was in Bubble. Turns out it’s there, it’s just not an operator… You just have to evaluate the state. This is one of those rare Bubble things that would be perplexing to both a beginner and an experienced developer. It’d be much nicer I think if there were also a :not or :inverse or :negate operator on Booleans and it’d feel much more obvious.)


Yeah, bubble is some times very confusing for my developer alter ego :slight_smile:

1 Like

Excellent trick, thanks Keith!!

Thank you so mucho @JonL for this, even though @keith idea works, the modulo idea is, in my understanding, better, because you just need to use only one event to do the toggle, instead with keith’s idea, you would need two events, because if you toggle in an action, then the following action goes back to what we just toggle before, so at the en is a double toggle, so doesn’t work in the same event…

1 Like

It really seams pretty simple, but I didn’t though about this before I read you.

Thank you!

Very clever solution! Thank you so much!!

@Keith this is a game changer for settings. Thank you!

For others working on their setting pages, this also works to modify database fields that are Yes/No. The example above shows modifications to custom states.

1 Like

Well done.

It’s been awhile this post is here. But maybe someone will find this useful. I found a much cleaner way to do it. It uses two state values. One is your yes/no, one is a number type. It goes like this:
Initial state value: yes and 1
Action 1
Set No if value is yes and if number is 1
Set number to 0
Action 2
Set Yes if value is no and if number is 1
Set number to 0
Action 3
Set number to 1

When one of the events is activated it sets the number to 0 blocking the next action. It’s like using a ‘block’ Uno card on the next player.

I hope this will help someone :slight_smile:


worked like a charm!
Cheers mate

1 Like

OMFG!!! You save me from a 2 days headache! Thanks!!!