# Change icon color by message

**URL:** <https://discourse.nodered.org/t/change-icon-color-by-message/56650>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [14 January 2022 11:35 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650 "2022-01-14T11:35:54Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [16 January 2022 20:40 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/21 "2022-01-16T20:40:50Z")

</div>

What a pity!  
But I like your idea with the background and I try to solve this on my own...  
Thank you!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 January 2022 00:35 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/22 "2022-01-17T00:35:32Z")

</div>

Do a forum search 'change button background color'

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [17 January 2022 00:47 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/23 "2022-01-17T00:47:08Z")

</div>

You can change Icon, Text or Background color within text, button or switch nodes and you need not to refresh the page like for template nodes.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 January 2022 01:11 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/24 "2022-01-17T01:11:12Z")

</div>

@mickym2 Just to clarify, you can change the 'icon' (i.e. use a diferent one), the color of the text and the background colot without refreshing the page.

However it you want to change the color of the icon, a refresh is needed...at least I haven't found a way to change it with out refreshing the page.

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [17 January 2022 01:21 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/25 "2022-01-17T01:21:23Z")

</div>

If I use a dashboard button I can change background, icon and icon color without refresh.

> **Zusammenfassung**
>
> ```auto
> [
> {
> "id": "8af46f36.a15e7",
> "type": "ui_button",
> "z": "a0bc94f0.ccb338",
> "name": "button",
> "group": "5a9fb243.0958dc",
> "order": 3,
> "width": "1",
> "height": "1",
> "passthru": false,
> "label": "",
> "tooltip": "",
> "color": "{{msg.color}}",
> "bgcolor": "var(--nr-dashboard-BackgroundColor)",
> "className": "",
> "icon": "{{msg.icon}}",
> "payload": "manual eco",
> "payloadType": "str",
> "topic": "",
> "topicType": "str",
> "x": 2330,
> "y": 1400,
> "wires": [
> []
> ]
> },
> {
> "id": "8b15d73b.2edfd8",
> "type": "inject",
> "z": "a0bc94f0.ccb338",
> "name": "",
> "props": [
> {
> "p": "icon",
> "v": "fa-thermometer-1 fa-2x",
> "vt": "str"
> },
> {
> "p": "color",
> "v": "orange",
> "vt": "str"
> }
> ],
> "repeat": "",
> "crontab": "",
> "once": false,
> "onceDelay": 0.1,
> "topic": "",
> "x": 2110,
> "y": 1380,
> "wires": [
> [
> "8af46f36.a15e7"
> ]
> ]
> },
> {
> "id": "6de4caee.ad2c44",
> "type": "inject",
> "z": "a0bc94f0.ccb338",
> "name": "",
> "props": [
> {
> "p": "icon",
> "v": "fa-bath fa-2x",
> "vt": "str"
> },
> {
> "p": "color",
> "v": "royalblue",
> "vt": "str"
> }
> ],
> "repeat": "",
> "crontab": "",
> "once": false,
> "onceDelay": 0.1,
> "topic": "",
> "x": 2110,
> "y": 1420,
> "wires": [
> [
> "8af46f36.a15e7"
> ]
> ]
> },
> {
> "id": "5a9fb243.0958dc",
> "type": "ui_group",
> "name": "Büro",
> "tab": "4ef2978d.961b48",
> "order": 1,
> "disp": true,
> "width": "6",
> "collapse": false
> },
> {
> "id": "4ef2978d.961b48",
> "type": "ui_tab",
> "name": "Heizung",
> "icon": "dashboard",
> "order": 3,
> "disabled": false,
> "hidden": false
> }
> ]
> 
> ```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/01ca74bb0af9526f19b665887f63a465932cd3af.png)

Same button modified by 2 inject Nodes. using msg.color and msg.icon and angular notation within the dashboard button

As background color I used the color scheme of the dashboard.

and I can do similar things with the text node and the switch node. The syntax is different, but it works for me,

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 January 2022 01:29 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/26 "2022-01-17T01:29:42Z")

</div>

> [@mickym2](#):
>
> Same button modified by 2 inject Nodes

Ahh, but try having a press of the button make the change....

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [17 January 2022 01:32 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/27 "2022-01-17T01:32:31Z")

</div>

I am not sure if I understand. If press the button - I cannot recognize any obstacles. If you mean - that the color should change when pressing the button - ok this is a different thing - but I haven't understood, that this would be the request. I thought that the request was that the color of the icon of the button should change dependent on different states.

Using text nodes with an Icon as value - I handle in the same way to reflect different states:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58093b6e9abd6fc18c2196abd890623cf9625050.png)

For switch Nodes - you can define different colors/icons for on/off directly within the node.

The only case, where I needed template nodes for a button were, when nodes/buttons should send a message with mouse button up and down - i.e. using for volume buttons etc.

I use this form of text nodes as standard to reflect status without any actions 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 January 2022 01:32 UTC](https://discourse.nodered.org/t/change-icon-color-by-message/56650/28 "2022-01-31T01:32:54Z")

</div>

Closed on 31 January 2022 01:32 UTC

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

[Previous page](https://discourse.nodered.org/t/change-icon-color-by-message/56650.md?page=1)
