Grow based on content

In Perspective there is the concept of grow, but it is based on child components with the same container. Is there any way to set a component to grow based on content inside itself? For instance if I have buttons and one has really short text and then another has a really long text I would want the buttons to auto adjust their width based on the content.

To my knowledge there’s no setting that will adjust the size (width) of a button based on text content, but you could always bind the basis (or the grow) of the component to the text value, and then transform it like this:

return str(len(value) * 8) + "px"

You can put the buttons in a flex container in ‘Row’ mode and set the flex parameters
grow:0; shrink: 0; base: auto;
With this settings, the buttons size is determined by the content width.

3 Likes

Thanks! I will try it out. I did not know about the secret auto value.

Ah, yah, I knew there was a way to do it, but I forgot about the auto setting.