2

I want to create a symbol that is a rectangle with text to the left. When I override the text, I want the total width of the symbol to stay the same. So if the new override text is longer, the rectangle will shorten to accommodate. If the new override text is shorter, the rectangle should lengthen to accommodate.

This seems like it should be really easy with Anima AutoLayout's stacks and padding, but I'm just not getting it. Can anyone help me or point me to a good tutorial on combining stacks, padding, and symbols?

Others have asked similar questions about the interaction of text and other layers in symbols here and here, for example, but none of them is asking quite the same thing.

Thanksvariable text label with accommodating text input box

3
  • sort of what I answered here graphicdesign.stackexchange.com/a/113413/16316 – Luciano Jan 7 '19 at 11:22
  • Hmm. In that scenario you have the luxury of a mask that stays the same size. Not sure how that would work here. Can you explain your idea more? – Brian R Jan 7 '19 at 18:25
  • Okay, I've thought about it a little more and I think I see what you're saying -- put the mask on the left and let the text override push some of the rectangle outside the mask. The problem with that is the border -- it would get pushed out of view so you'd have to make a thin rectangle to mimic that right border and pin it the the right edge of the mask. But that's pretty clunky. I'm hoping there's a more elegant solution! – Brian R Jan 7 '19 at 20:18
1

It's sort of achievable with Anima:

  1. Download and install Anima, it's free to use;

  2. Create a text layer and a shape layer, group them;

  3. Tweak the settings of the text layer following the instructions on the image;Text Layer Settings

  4. Tweak the settings of the shape layer following the instructions on the image;Shape Layer Settings

  5. Select the group, in Anima's panel, click stack, set the spacing.Anima settings

  6. Because Anima will try to lock the shape layer's "Fix Size" property if you create a symbol from the group, so you can't make it a symbol.

  7. Copy and paste the group, alter the text, then Anima will rearrange for you, it will look like this;Copy and Alter

  8. Since their total width are the same, you can select them all and alter the width in the properties panel;Alter Property

  9. Kinda worked out.Done

I know this is probably not the perfect automated solution you're looking for, but Anima is not very stable, especially in symbol.

1
  • Thanks, Amyas. Yes, it looks like this is the best I'm going to get for now. – Brian R Jan 25 '19 at 20:30
1

I know this an old post but I randomly stumbled here while looking to solve my own goofy issues and thought this would be more fun to try and solve than my problem.

With two caveats I think this is as close as I could get in Sketch...

  1. You will need to make nested symbols
  2. You will need to resize the symbol after text override (If symbol is 480px wide and you change text it will become wider, so you'll need to drag a transform handle on the object back to 480)

I: Build a label symbol

  • Text objects: no pinning, fixed size height - But ALIGNMENT AUTO does matter
  • Create symbol from from your object: Layout horizontal with align left Label Symbol details

II: Build an input box symbol

  • Input objects: Pin left and right, fixed size height
  • Create symbol from from your object: Layout horizontal with align left Input Symbol details

III: Build a form symbol

  • Label symbol: No pinning, no fixed size
  • Input symbol: Pin horizontal left edge Form Symbol details

IV: Test your form symbol

  • Place symbol and type label title (Default symbol text will NOT hold box position)
  • Manually fix your width again Symbol in use

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.