# Dashboard widgets, msg.className should append to not replace widget's Class

**URL:** https://discourse.nodered.org/t/dashboard-widgets-msg-classname-should-append-to-not-replace-widgets-class/77363
**Category:** Feature Requests
**Tags:** node-red-dashboard
**Created:** [8 April 2023 12:17 UTC](https://discourse.nodered.org/t/dashboard-widgets-msg-classname-should-append-to-not-replace-widgets-class/77363 "2023-04-08T12:17:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [8 April 2023 12:17 UTC](https://discourse.nodered.org/t/dashboard-widgets-msg-classname-should-append-to-not-replace-widgets-class/77363/1 "2023-04-08T12:17:03Z")

</div>

Dashboard widgets eg switches can defined as Class "STEAM" in the editor.  
Now groups of widgets can be styled alike across dashboard tabs and groups  
The CSS path is

```auto
... md-card.nr-dashboard-switch.[blah].STEAM.visible

```

If you pass msg.className "GREEN" to a widget it's CSS path becomes

```auto
... md-card.nr-dashboard-switch [blah].GREEN.visible

```

(GREEN replaces STEAM)  
Would it be better to append msg.className? Giving

```auto
... md-card.nr-dashboard-switch[blah].STEAM.GREEN.visible

```

Now all the STEAM widgets can retain STEAM styling (background colour?) and also show GREEN (border green?)

With this modification a null msg.className would have to remove .GREEN but retain .STEAM

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [8 April 2023 12:30 UTC](https://discourse.nodered.org/t/dashboard-widgets-msg-classname-should-append-to-not-replace-widgets-class/77363/2 "2023-04-08T12:30:13Z")

</div>

> [@jbudd](#):
>
> With this modification a null msg.className would have to remove .GREEN but retain .STEAM

I think this would be hard to manage, given there could be none to many classes on the widget ?

I haven't tried but can you send steam and green together to do what you want, ie have 2 classes ?

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [8 April 2023 12:41 UTC](https://discourse.nodered.org/t/dashboard-widgets-msg-classname-should-append-to-not-replace-widgets-class/77363/3 "2023-04-08T12:41:49Z")

</div>

I have sent more than one class in msg.className.  
I _think_ it was a simple list "myclass alert".

At the moment you can give groups a class in the editor but once you use msg.className they lose that. No doubt it's simpler to code but less flexible for the user.

---

<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: [8 May 2023 12:41 UTC](https://discourse.nodered.org/t/dashboard-widgets-msg-classname-should-append-to-not-replace-widgets-class/77363/4 "2023-05-08T12:41:58Z")

</div>

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