# Dynamically changing node color or label

**URL:** <https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669>\
**Category:** Developing Nodes\
**Created:** [3 October 2018 22:19 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669 "2018-10-03T22:19:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mountaindude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mountaindude/32/27713_2.png) [@mountaindude](https://discourse.nodered.org/u/mountaindude)\
**Post date:** [3 October 2018 22:19 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/1 "2018-10-03T22:19:03Z")

</div>

I would like to dynamically change either the label or background color of nodes in a flow, when certain MQTT messages arrive. I know, that's slightly unusual, but I have a pretty specific use case where this makes sense (monitoring of a dozen or two of batch job states, where Node-RED is perfect as it allows for very powerful logic for controlling when/how each batch job is triggered).

I could probably use the UI elements of the dashboard.. but then I have to write custom html code etc. Don't want to go there, as Node-RED's regular flow view is very close to what I need.

The MQTT side works well, I can also change the node's status based on the MQTT messages (one strange thing there tho: no matter what I set the node's initial status to, it always shows up as green and "connected". Inherited from the MQTT config node somehow?).

The status indicators are kind of small though... I would prefer to have the node's background color change to red when certain error conditions occur, for example.

The docs are pretty clear that labels are not dynamically generated ([https://nodered.org/docs/creating-nodes/appearance](https://nodered.org/docs/creating-nodes/appearance)), but is that the case also for background color? I can't find anything in the docs stating this, giving me some hope it might be possible. Is it?

Thanks!

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [3 October 2018 22:34 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/3 "2018-10-03T22:34:35Z")

</div>

Hi @mountaindude - the node colour cannot be changed dynamically. The Editor is not meant to be used as a dashboard to reflect runtime state. The only thing the runtime can modify is the status indicator - [https://nodered.org/docs/creating-nodes/status](https://nodered.org/docs/creating-nodes/status)

---

<div class="post-metadata">

**Author:** ![tilleul](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tilleul/32/78_2.png) [@tilleul](https://discourse.nodered.org/u/tilleul)\
**Post date:** [4 October 2018 07:38 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/4 "2018-10-04T07:38:34Z")

</div>

Hypothetically, "IF" there was an access to the runtime event emitter, it would be possible, no ?  
Something like `RED.events.emit("myCustomEvent")`in the node JS file and something like `RED.events.on("myCustomEvent", callback )` in the node HTML file ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 October 2018 07:55 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/5 "2018-10-04T07:55:30Z")

</div>

hypothetically - If you really wanted to spend a lot of time sending things over websockets and killing whatever performance your Pi has left then ...

But as the editor is not a dashboard it won't be a problem.

---

<div class="post-metadata">

**Author:** ![tilleul](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tilleul/32/78_2.png) [@tilleul](https://discourse.nodered.org/u/tilleul)\
**Post date:** [4 October 2018 08:15 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/6 "2018-10-04T08:15:12Z")

</div>

I agree. There are already numerous ways to display "running" info in the NR editor: status, debug, console, ...

---

<div class="post-metadata">

**Author:** ![fangzhu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fangzhu/32/5796_2.png) [@fangzhu](https://discourse.nodered.org/u/fangzhu)\
**Post date:** [20 August 2019 08:33 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/7 "2019-08-20T08:33:23Z")

</div>

Hi @knolleary - I understand the background color cannot be changed dynamically at runtime as required by this topic. Would it be able to change the color when creating the flow by providing the color as a property of the node?  
Our users want to use the same node in different flows for slightly different purpose. I understand now user can change the icons through the node setup, is it possible to change background color in the same way?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 August 2019 08:34 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/8 "2019-08-20T08:34:47Z")

</div>

No, a node's colour cannot be changed, with one new exception - in 1.0, a Subflow node can have its colour set.

---

<div class="post-metadata">

**Author:** ![fangzhu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fangzhu/32/5796_2.png) [@fangzhu](https://discourse.nodered.org/u/fangzhu)\
**Post date:** [20 August 2019 08:40 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/9 "2019-08-20T08:40:48Z")

</div>

Thanks! I see it is not in the latest beta yet. I am looking forward to seeing it in the next beta or actual 1.0.

---

<div class="post-metadata">

**Author:** ![meijey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meijey/32/96575_2.png) [@meijey](https://discourse.nodered.org/u/meijey)\
**Post date:** [14 November 2022 11:15 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/10 "2022-11-14T11:15:10Z")

</div>

Hi. Sry to reopen such an old discussion, but I wanted to ask if there is still no (official) way in Node-RED 3 to dynamically change a node color or label.

I have an internal project where it would be nice to not only change the status but also the nodes groups color (= all nodes of a type in the active workspace).  
I have found a semi-working way to do that by changing the nodes \_def color and changing to another workflow tab.  
The RED.view.redraw() alone doesn't do the trick, are there some flags which must be set?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 November 2022 17:48 UTC](https://discourse.nodered.org/t/dynamically-changing-node-color-or-label/3669/11 "2022-11-14T17:48:40Z")

</div>

> [@meijey](#):
>
> if there is still no (official) way in Node-RED 3 to dynamically change a node color or label.

No, there isn't.

> [@meijey](#):
>
> I have an internal project where it would be nice to not only change the status but also

The "official" answer is that the Editor is not a status display. Of course, that message has somewhat been watered down over the years but it remains the case.

But then, the Editor IS "just" a web-page, a very complex and clever one to be sure, but still, you do get an amazing level of control over web pages.
