Wrapping (or newline) in Node with Long Title

I'd prefer to give my nodes longer title. For example "Only Office Lamp button single/double output". That certainly works fine, but the node ends of physically long on the canvas. I'd much prefer Node-RED to wrap the title into two or three lines, which would give me a taller (but less wide) node, which makes a longer flow more compact. I'd be happy with either an auto-wrap, or perhaps a newline character that I could use within the Node title

Welcome to the forum.
\n is your friend! put \n at the end of each line of the name of your node.

[{"id":"f357dd80.704a","type":"inject","z":"cff6b188.f8ac2","name":"This is a node name\\n with multiple\\n lines","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":360,"wires":[[]]}]
1 Like

Hmm, that's encouraging !

Just tried it, no joy. Exported so I could see a view similar to yours, and have now discovered that the GUI seems to be escaping my line returns for me, which I guess is polite of it :slight_smile:

[{"id":"574cddf.aa6db24","type":"switch","z":"209e3a96.199a46","name":"Only\\n\"Office Desk Lamp\"\\nButton","property":"payload.event.device_ieee","propertyType":"msg","rules":[{"t":"eq","v":"00:15:8d:00:02:8f:47:ea","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":440,"y":220,"wires":[["89bc184e.bec558"]]}]

Maybe I have to edit via CLI ? Unsure how to do that in Node-Red, still getting the hang of it, my first day

What do you mean CLI?

You have quotes in your name, you don't need quotes!

Like this:
First line \n Second line \n

Yup, sorry for confusion, was just adding quotes for convenience, let me post an example without it...

Here's a simpler example, just took inject node, and gave it a name with \n in it. Node-Red GUI seems to be escaping it.

[{"id":"f27e47fa.343358","type":"inject","z":"a94fa564.915bb8","name":"First line of Name\\nSecond line of name","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":600,"y":1040,"wires":[[]]}]

Here's what the GUI actually looks like:

If it's meaningful, I'm using Node-Red as an Add-on to Home Assistant

Put a space after /n

1 Like

Hazaahh !!! That works :slight_smile: Thanks @ghayne (weird, but works)


1 Like

We had to add the requirement for the space otherwise too many nodes with names like c:\node-red\foo would break lines when you didn’t want them to.


Ahhh, makes sense ! Experience is a wonderful teacher, thanks for sharing your experience :slight_smile:

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