Skip Navigation

Resizing Symbols with Smart Layout

Smart Layout maintains the padding and spacing between layers in a Symbol when an override changes its size. Once you‘ve set up Smart Layout, changing an override in a Symbol‘s instance will resize it automatically.

A basic button Symbol, set to resize horizontally from the middle.

To use Smart Layout, simply create a Symbol and give it either horizontal or vertical layout. When you create an instance of that Symbol and edit its overrides, Smart Layout will use the spacing and padding between layers in the Symbol Source as a blueprint and keep them consistent in your instance as it resizes.

Note: When you apply Smart Layout properties to a Symbol, you should avoid manually resizing any instances of it. Doing so may cause your Symbol to look or behave unexpectedly. To manually resize a Symbol instance with Smart Layout properties, you’ll either need to detach it or remove those Smart Layout properties from the Symbol Source.

How to use Smart Layout with Symbols

You can set Smart Layout properties in the Inspector (when you edit an existing Symbol Source) or when you create a new Symbol.

To use Smart Layout with an existing Symbol, head to its Source (you can get there quickly by selecting any instance of that Symbol and pressing Enter on your keyboard) and choose how you‘d like Smart Layout to resize it under the Layout panel in the Inspector.

An image showing smart layout controls in the inspector in the Mac app

This Symbol is set to resize horizontally from the middle. Depending on whether you choose a horizontal or vertical layout, the properties row below will show different options.

As well as choosing whether your Symbol resizes horizontally or vertically, you‘ll need to set which direction it resizes from (think of it a bit like text alignment). You can choose from the following layout properties:

  • Vertical:
    • Top to Bottom VerticalTop to bottom Alignment (Smart Layout )
    • Bottom to Top Vertical Bottom to Top Alignment (Smart Layout )
    • From Middle Vertical Middle Alignment (Smart Layout )
  • Horizontal:
    • Left to Right Horizontal Left to Right  (Smart Layout )
    • Right to Left Horizontal Right to Left  (Smart Layout )
    • From Center Vertical Middle Alignment (Smart Layout )

When you create a new Symbol, you’ll be able set these properties using the drop-down menu underneath the name field in the Create New Symbol sheet.

Note: When you apply Smart Layout properties to a Symbol with text layers, you’ll need to make sure they’re set to either auto height Auto Height (for vertical layouts) or auto width auto(width) (for horizontal layouts). Smart Layout compares the dimensions of the Text Layer in the Symbol Source to the one in the instance to work out how the other layers in the Symbol should resize, so fixed size text layers will not work as they always stay the same.

When you give a Symbol Smart Layout properties, you’ll see a new icon next to its name in the Layer List showing its layout direction.

Smart Layout icons in the Layer List

If you change the layout of a Symbol Source when it already had Smart Layout properties set up, instances of that Symbol may look wrong. To fix this, try clicking the Shrink instance to fit content button that appears under the overrides panel in the Inspector.

Note: You can still apply Resizing Constraints to layers within a Symbol that has Smart Layout properties. This is handy if you want a specific layer to ignore the layout settings you‘ve given the Symbol it‘s a part of. For example, you can use Resizing Constraints to fix a layer‘s size and stop it from resizing with a Symbol instance that has a horizontal or vertical layout.

How to set minimum Smart Layout dimensions

When you choose Smart Layout properties for a Symbol, you‘ll see a field for minimum height (for vertical layouts) or minimum width (for horizontal layouts) under the Layout panel in the Inspector.

This button’s label is quite short and its Smart Layout settings mean it has resized to be quite small, but setting a minimum width of 90, we can make sure it stays a reasonable size.

Adding dimensions to these fields will stop your Symbol shrinking below a minimum size, regardless of its override content. If you leave these fields blank, your Symbol will shrink to any size to fit its content.

Note: Minimum Smart Layout dimensions are only available in Sketch 62 and above and do not currently apply to groups within Symbols.

How to use multiple Smart Layout properties within a Symbol

For more complex UI components, you might want to include a horizontal layout within a vertical layout (or vice versa), like the example below. For this, you can apply Smart Layout properties to groups within a Symbol Source to have different sets of layers resize in different directions.

This card Symbol has a vertical layout and resizes from the top down. But the two buttons at the bottom are also grouped, have a horizontal layout and resize from right to left.

To do this, open up the Symbol Source, select the objects that you want to resize in a different direction, and group them. Now you can apply a separate set of Smart Layout properties to that group under the Layout panel in the Inspector. Like Symbols themselves, you’ll see a new group icon Group in the Layer List showing you their layout direction.

If you have a Symbol where one of its layers dictates that Symbol‘s minimum height (like the image in this card example below), applying an override to a shorter text layer next to it would cause the Symbol to resize with unnecessary padding. If that‘s the case, you’ll need to group the text layer(s) and the layer that dictates the Symbol‘s minimum height together in the Symbol Source. Once that‘s done, you‘ll be able override the text layer and Smart Layout will know not to increase the overall Symbol height until the text passes its minimum height.

This card Symbol has a minimum height that‘s dictated by the image layer. By grouping the text layers and image layer together, you can make sure that any text overrides dont cause the Symbol to resize with unnecessary padding.

How to use Smart Layout with hidden Symbols

Smart Layout doesn‘t just work when overrides change the size of a Symbol instance, it also works when you hide a Symbol. For this to work, you‘ll need a set of Nested Symbols that follow the direction of the Symbol Source‘s layout (a row of buttons in a menu with a horizontal layout, for example). Hiding one of those Symbols via the overrides panel will cause the others to move up and fill the empty spot. This even works for Symbols of different heights and widths.

This navigation menu Symbol has a horizontal layout and a row of button Symbols within it. When one of buttons is hidden using the overrides menu, the surrounding buttons to move to close the gap.

Last updated on 21 Apr 2021

Was this article useful?

We’re really sorry about that.
Please let us know what you were looking for:

If you need more help or you’d like to report a bug with this content, please contact support.

Thanks for your feedback.
An error occurred, please try again later.