Vertical stack: disabled text leaves empty space

Hi,

I’m building a simple component using a vertical stack with a label and a description.

In order to add padding around each text, I need to wrap them in an extra group or stack. However, groups and stacks don’t have an enable/disable switch in instances. When I turn off the text override, the text disappears, but the wrapper group/stack remains, so the vertical stack still preserves the empty space.

When using plain text layers (without wrapping), disabling the text correctly collapses the layout and the component height shrinks. But once wrappers are needed for spacing, this behavior is lost, making it harder to build flexible components with optional elements.

Thanks a lot!

Hey @leohans, hope you’re doing well!

Could you share a sample document with us? We’d love to try and get this to work for you! :folded_hands:

You could also try hiding (Select element(s) on the Layer list within the Symbol Instance, and press ⌫ Backspace) the Stack where the text element is. That might do the trick, but then again, we’d love to verify using your current setup!

Yes, hiding the layer works, but it’s not the most elegant solution, especially when building reusable components.

Ideally, the layout should adapt automatically when optional content is disabled, without requiring manual visibility toggles.

Thanks a lot

Test.sketch (436.9 KB)

Hey @leohans thanks for sharing that doc!

We can recommend:

  • Convert those elements into Symbols (So they become Overrides on the main Component).
  • Now you can toggle their visibility from the Inspector without having to hide them.
  • The functionality is basically the same, but in this case you’re using Overrides to show/hide the element and this will adjust the layout to account for the different in height.

Let us know if this works!

Test_rev.sketch (437.4 KB)

I think is a nice to have the option to convert any layer into an optional part of the component without needing to create symbols.

Thank you!

1 Like

Hi Leo. :waving_hand:
This is a little bit of a quirky solution, I admit, but you might find this method to be useful for you. You can use the Alignment override to get the same result. No additional Symbols, and no additional Stacks.

1 Like