How to expand an item horizontally inside a vertical flex?

I’m trying to develop a plugin to create sticky notes for my designs.

The plugin so far does the following:

  • Creates a Board with a fixed square size and adds colors, shadows and so on
  • Attaches a Flex Layout to it and sets it as column
  • Adds Text with a specific content

But the thing I haven’t been able to do is to expand this text to use the 100% of it’s parent Board such as when one presses “FLEX ELEMENT / Widh 100%”. I could hardcode the text size with .resize() but that’s not ideal. I have tried a lot of different properties but none seems to do the job so far :frowning:

Can anybody help me on how to replicate that function using the plugin API?

1 Like

Change the horizontalSizing property.

TextNode.layoutChild.horizontalSizing = 'fill';

In the same way you can change the verticalSizing property.

1 Like

It worked! Thank you!

That was actually one of the properties I tried, but I realized that I was calling it before adding the text element as a child of the board. At that point layoutChild was null so it didn’t work. When I set that property after calling board.addChild(text) it worked perfectly.

Maybe the docs could be improved by explaining how does the layoutChild property work because “Layout properties for children of the shape” made me think of some node that was a child of the TextNode and not in the layout of the TextNode itself.

1 Like