# Color Change based on the Integer Value in Perspective

**URL:** <https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150>\
**Category:** Ignition\
**Tags:** perspective, vision\
**Created:** [August 21, 2023, 12:05pm UTC](https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150 "2023-08-21T12:05:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![suram-in](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/suram-in/32/51348_2.png) [@suram-in](https://forum.inductiveautomation.com/u/suram-in)\
**Post date:** [August 21, 2023, 12:05pm UTC](https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150/1 "2023-08-21T12:05:36Z")

</div>

Hi, I would like to change the text color of the Label based on the integer value varies between 0- 100. For Few values I need to flash the color of the text. I already did the same using Vision using style customizer but how to do the same in Perspective?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 21, 2023, 12:26pm UTC](https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150/2 "2023-08-21T12:26:52Z")

</div>

> [@suram-in](#):
>
> I would like to change the text color of the Label based on the integer value varies between 0- 100

How many colors? What are the limits for each color to be used?

You haven't given enough definition to what you are trying to accomplish for anyone to really be able to help you.

You know what you want but we don't, you have to tell us.

Generally:

1. Add the `color` key to your style for the label.
2. Add an expression binding to the `color` key.

```auto
if(self.custom.integerValue < 50,"#00FF00","#FF0000")

```

Although I have used hard coded values here, I would strongly recommend that you stay away from "magic numbers". Look into style sheets, style classes, and/or themes depending on the version of Ignition you are using. CSS variables are much better, and will allow you to more easily manage your theming throughout the project. So _when_ a color needs to change you can change it in one place instead of hundreds.

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [August 21, 2023, 12:32pm UTC](https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150/3 "2023-08-21T12:32:48Z")

</div>

Try like below expression:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b9910f96608fad517be5d741f43e3840f64b8a68.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/9/69392b3c1d8dc918279b8333baf9a3a487297ea9.png)

Add color property from the style.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/e/bef333d8c20584fc362a3b5800256883ae1c5d43.png)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 21, 2023, 12:57pm UTC](https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150/4 "2023-08-21T12:57:55Z")

</div>

> [@suram-in](#):
>
> For Few values I need to flash the color of the text.

Styles, either creating Perspective styles or using the newer stylesheet, is the best approach, especially if you are wanting animation (flash/blink). It's possible to blink colors outside of styles, but it can get a bit messy.

Using the examples already posted in the topic, instead pointing to a color, point to a style. The expression will be bound to the style --\> classes.

---

<div class="post-metadata">

**Author:** ![suram-in](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/suram-in/32/51348_2.png) [@suram-in](https://forum.inductiveautomation.com/u/suram-in)\
**Post date:** [August 21, 2023, 2:04pm UTC](https://forum.inductiveautomation.com/t/color-change-based-on-the-integer-value-in-perspective/78150/5 "2023-08-21T14:04:27Z")

</div>

Thank You Everyone, I plan to use the Styles for different colors including flashes and I will use the Map Transform to assign Styles to the values on the label.
