Use text and icons as a 'knockout' mask

I would like to make a button component where the text and icons inside the button are see through so that you can see the background behind the button. I don’t think it’s possible to do this at the moment with the usual auto layout properties. I can make one where the text masks the button but not the inverse. It’s possible to do it with Boolean Groups ‘Subtract’ setting but then you lose the ability to set auto layout.

The end result would be a toggle button where the on state is a reversed out version of the off state.

If I understand you correctly, you want to subtract text and icon from background and have auto layout? You can duplicate my file to see how it’s done:


Many thanks! That’s actually quite clever, I don’t think it would have occurred to me to use a component text property to duplicate the text fields, very neat!

I’ll save that solution - would still be a nice feature to be able to reverse the masks or use auto layout within the Boolean Groups with out this ‘hack’ but it does work well. Wonder if it would also work for icon + text situations? Would it use an icon property?

Yes, sure! This is done in exactly the same way as with text, only the instance swap property is used instead of the text property.
Just add two identical icons (one to shift the text in auto layout, one to subtract from the background) and apply the same instance swap property to those icons.

1 Like

Brilliant! Thanks again :slight_smile:

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