# Changing Background Color Based on State Content

**URL:** <https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767>\
**Category:** Need help\
**Created:** [March 17, 2021, 5:29pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767 "2021-03-17T17:29:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 5:29pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/1 "2021-03-17T17:29:22Z")

</div>

I have created a repeating group toggle-type menu that sets a state (called Genre Button) based on the app data source (Genre) for the repeating group. I am wanting to change the background color based on the state’s specific content, but am not able to enter that into the conditional formatting.

I want to say when [pagename]'s Genre Button is Action (action is one of the items in the Genre data)… but when I type action (or drama or any of the other genres) It doesn’t work.

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 17, 2021, 5:37pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/2 "2021-03-17T17:37:58Z")

</div>

What do you mean ‘it doesn’t work’?

The conditional isn’t being applied? Or it won’t give you the option to change the background colour?

There’s not enough info to diagnose the issue.

What ‘type’ is the state? Maybe a few screenshots, or more detailed info would help.

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 5:43pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/3 "2021-03-17T17:43:39Z")

</div>

Thanks. Sorry for the lack of clarity. I mean when I type action and press enter. it is red and doesn’t save/work/do anything. If I click out of the box, the word I typed disappears

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 17, 2021, 5:45pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/4 "2021-03-17T17:45:02Z")

</div>

It’s red… but is the value there? Or does the value not get entered?

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 5:47pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/5 "2021-03-17T17:47:17Z")

</div>

Yes. the value ultimately is not entered.

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 5:47pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/6 "2021-03-17T17:47:50Z")

</div>

do i have to put it ins quotes or apostrophes?

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 5:51pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/7 "2021-03-17T17:51:49Z")

</div>

Here are some screenshots that show whats happening.

 ![Screen Shot 2021-03-17 at 10.50.28 AM](https://us1.discourse-cdn.com/bubble/original/3X/e/7/e7ab1a4d2df09dfe587cb76a7a0405329edab758.jpeg) ![Screen Shot 2021-03-17 at 10.50.38 AM](https://us1.discourse-cdn.com/bubble/original/3X/9/b/9b87ad8bdcae98cb725d7597f503a0ec053d17a0.jpeg) ![Screen Shot 2021-03-17 at 10.50.51 AM](https://us1.discourse-cdn.com/bubble/original/3X/b/5/b5d722fdebecf61fda23bb58a94ceb32b0bc7180.jpeg)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 17, 2021, 5:55pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/8 "2021-03-17T17:55:34Z")

</div>

What ‘type’ is the custom state?

If it’s a text then you should just be able to type a value into the conditional, so the fact it’s not letting you suggests it’s not a text?

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 5:57pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/9 "2021-03-17T17:57:45Z")

</div>

Yeah. the state type is Genre… which is part of the app data.

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 6:03pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/10 "2021-03-17T18:03:38Z")

</div>

Here’s the screenshot of the genre data type:

 ![Screen Shot 2021-03-17 at 11.03.04 AM](https://us1.discourse-cdn.com/bubble/original/3X/c/1/c19a586211fe270a51158bbf4036ac26d760c3fb.jpeg)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 17, 2021, 6:15pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/11 "2021-03-17T18:15:52Z")

</div>

Ok, so there’s your answer - you can’t give a ‘text’ value if the value needs to be a datatype (a Genre).

You need to refer to an actual specific ‘Genre’ (DB entry) - either by referencing a datasource on the page, (i.e. Group A’s Genre), or by doing a search for Genres and selecting a specific entry. (e.g. search for Genres, who’s name is Action, first item).

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 6:26pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/12 "2021-03-17T18:26:17Z")

</div>

thank you so much! Don’t know what that didn’t occur to me! Actually I do. It’s because I’m a noob lol.

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 6:37pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/13 "2021-03-17T18:37:41Z")

</div>

One last question for another implementation. In a workflow, can I manually set a state to be a specific name in Genre? When I set state and then do a search for genre whose name is action, it doens’t seem to work.

I’m trying to do a simlar thing I have set up for the repeating group with buttons that come from a search for genres but with static buttons. Basically an “Action” button that is static and always sets the state of “genre button” to be Genre’s Name is Action

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 17, 2021, 7:01pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/14 "2021-03-17T19:01:10Z")

</div>

Yes, you can set the value of the state in a workflow, using the same method (search for Genres, who’s name is Action, first Item).

Although if your Button is inside a repeating group which (presumably) has a content type of Genre, then all you need to do is set the state to be the current cell’s genre.

Another thing that you might want to look into is using Option Sets for this instead of database entries.

It looks as though Option Sets are perfectly suited to what you’re trying to do (but without knowing more about your app I can’t say for sure).

But using option sets would simplify the process, and make it faster, as there’s no need to do any database searches. So it might be worth looking into.

You could also store the colour on the Genre (whether you use option sets or stick with database entries), then set the background colour dynamically to be the state’s Genre’s colour. That way you don’t need to use conditionals to set the background colour.

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 7:08pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/15 "2021-03-17T19:08:12Z")

</div>

I can’t seem to get the commands you mention to come up when I’m setting this state. see screenshot. There was no “is” so I used “contains” and then there is no first item. See screenshot below:

 ![Screen Shot 2021-03-17 at 12.06.11 PM](https://us1.discourse-cdn.com/bubble/original/3X/9/5/950e2267713c8bbee525904b056431c3a8521e7f.jpeg)

---

<div class="post-metadata">

**Author:** ![hacker](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/hacker/32/88281_2.png) [@hacker](https://forum.bubble.io/u/hacker)\
**Post date:** [March 17, 2021, 7:11pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/16 "2021-03-17T19:11:34Z")

</div>

Hey, @zoay,

In the search contraints you can have a contraint when the Name = whatever you want 🙂 💻

---

<div class="post-metadata">

**Author:** ![zoay](https://avatars.discourse-cdn.com/v4/letter/z/9dc877/32.png) [@zoay](https://forum.bubble.io/u/zoay)\
**Post date:** [March 17, 2021, 7:16pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/17 "2021-03-17T19:16:53Z")

</div>

Thats what I tried initially, but it doesn’t allow me to input text there even though Genre name is a text field. see screenshot

 ![Screen Shot 2021-03-17 at 12.15.38 PM](https://us1.discourse-cdn.com/bubble/original/3X/0/c/0c2329d8f37630369d4e20016d60850c2ea25455.jpeg)

---

<div class="post-metadata">

**Author:** ![hacker](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/hacker/32/88281_2.png) [@hacker](https://forum.bubble.io/u/hacker)\
**Post date:** [March 17, 2021, 7:20pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/18 "2021-03-17T19:20:03Z")

</div>

That´s weird, try deleting the condition and do the same again.

If it doesn’t work, try having a filter in the search and inside the filter add the “Name = whatever”

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 17, 2021, 7:52pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/19 "2021-03-17T19:52:13Z")

</div>

Make sure you click in the actual input box, and not on the ‘click’ button (which will just open the dropdown of expressions). As long as your name field is a ‘text’ type you should be able to type it’s value.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/3/5/350ce2e359e3cf9a6fb435961f7731f3807d632d.png)

Additional note: also be aware that searches are case sensitive - on some of your earlier posts you were typing ‘Action’ whereas on the last post you typed ‘action’.

These are different values, so you’ll need to make sure you use the one that matches your data entry.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [May 26, 2021, 5:29pm UTC](https://forum.bubble.io/t/changing-background-color-based-on-state-content/141767/20 "2021-05-26T17:29:53Z")

</div>

Closed on May 26, 2021, 5:29pm UTC

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