Text Node - text format

Hi

I wish to change the data in the 'value format' line to not be bold (just normal text).

I tried {{msg.payload}}

This does not work (however font color='green' does work).

Any ideas?

Some formatting gets removed by the node.

But you can do this with a template node.

Add a template node with Template type widget in group, then select the same group as your text node, set size set to auto with the following content, then any text nodes on that TAB will have "normal" font weight.

<style>
.nr-dashboard-text .value {
font-weight: normal;
}
</style>

If you want to change this for all text nodes on all tabs then set Template type to added to site head section

The 3rd option is to target specific text nodes. To do this enter a class name in the text nodes you want to target eg "my_text" then with the template set to added to site head section modify the the target like so.

<style>
.my_text .value {
font-weight: normal;
}
</style>

Then any nodes with the class my_text will be "normal" font weight.

Thank you.... The first option 'widget in group' changed things for the whole flow (not just the group).

So I tried the 3rd option - which is really what I require.

image

Unfortunately this is not working for me.... Any thoughts?

  1. You should have only style declaration in the ui_template
  2. Don't connect any wires to that template.

Perfect, thank you.....

Is there a way of changing between two ui_templates?

Or more simply, is there any way of (for example) using msg.topic as the </> Class in a text node?

For example, can I set text bold if x is true, and text as normal if x is false?

You can change the class by sending msg.className = 'name_of_the_class'

1 Like

Thank you - that works great :slight_smile:

And don't make more than one template for CSS. Just add rules to existing one.

image

To make things flexible and easy to use, make your classes so you can use them in combination.

Example:

[{"id":"259c38a3aaa1a43b","type":"ui_template","z":"09deee63c1b960f7","group":"c7a27394.057878","name":"Dashboard CSS","order":9,"width":0,"height":0,"format":"<style id=\"my-styles\">\n    .my_text_regular .value{\n        font-weight:normal;\n    }\n    .my_text_bold .value{\n        font-weight:bold;\n    }\n    .my_text_red .value{        \n        color:red;\n    }\n    .my_text_green .value{\n        color:green;\n    }\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"global","className":"","x":520,"y":2200,"wires":[[]]},{"id":"82890ba2beba3347","type":"function","z":"09deee63c1b960f7","name":"choose css class ","func":"let data = msg.payload\n\nif (data > 200) {   \n    msg.className = \"my_text_red my_text_bold\"\n}\nelse if(data > 150){\n    msg.className = \"my_text_bold\"\n}\nelse if (data > 100) {\n    msg.className = \"my_text_bold my_text_green\"\n}\nelse if(data > 50){\n    msg.className = \"my_text_regular my_text_green\"\n}\nelse {\n    msg.className = \"my_text_regular\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":2260,"wires":[["7fa7a07fe2814d5d"]]},{"id":"7fa7a07fe2814d5d","type":"ui_text","z":"09deee63c1b960f7","group":"08ac9b242ae51e8c","order":10,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","x":750,"y":2260,"wires":[]},{"id":"e072150d4dbcc442","type":"ui_slider","z":"09deee63c1b960f7","name":"","label":"slider","tooltip":"","group":"08ac9b242ae51e8c","order":11,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"msg","min":0,"max":"300","step":"10","className":"","x":310,"y":2260,"wires":[["82890ba2beba3347"]]},{"id":"c7a27394.057878","type":"ui_group","name":"aha","tab":"54e197d8.7f7fe8","order":2,"disp":false,"width":"9","collapse":false,"className":""},{"id":"08ac9b242ae51e8c","type":"ui_group","name":"Default","tab":"2acb95821445c8af","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"54e197d8.7f7fe8","type":"ui_tab","name":"key","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"2acb95821445c8af","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
1 Like

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