Multiline Category Name

35 views
Skip to first unread message

Erin Carvalho

unread,
Sep 2, 2021, 4:33:05 PM9/2/21
to Blockly
Hey all,

I can't see to find this anywhere so I figured I'd post. I have a div containing a blockly workspace as part of a larger web app. A few of my category names in the toolbox are somewhat long and I would like to break them up into multiline names. I am defining the category with JSON. I've tried using <br/> and \n with no luck. Any help is appreciated.

Best,
Erin

Abby Schmiedt

unread,
Sep 7, 2021, 9:06:44 PM9/7/21
to Blockly
Hello!

So we don't really support this out of the box. In the category we set labelSpan.textContent='nameYouPassedIn'. I think the fact that we use textContent is the reason why using <br> does not work.

You can create a custom category that overrides createLabelDom_. In here you will probably want to do something like below:
toolboxLabel.appendChild(firstHalfOfWord);
toolboxLabel.appendChild(document.createElement('br'))
toolboxLabel.appendChild(secondHalfOfWord);

Hope that helps and let me know if you have any other questions!

Cheers,
Abby
Reply all
Reply to author
Forward
0 new messages