Responsive Flex Grid in Sketch using AutoLayout and Stack Groups

Improving design systems for structure, modularity, and scale

Alan Roy
Alan Roy
Feb 13, 2017 · 4 min read

Tools like FlexBox in CSS, UIStackView in iOS, and FlexboxLayout in Android have long given developers the necessary workflows to handle the multitudes of adaptive and responsive views that exist today.

For designers however, the layout design process in some of our favorite design tools have always been more manual, more static, more tedious, and generally less mathematically precise. But thanks to the amazing work by the folks at Anima, we may soon have the structure and flexibility we need to better bridge that gap.

With the new Stacks feature that is bundled into the latest Auto-Layout plugin, we now have a workflow that accommodates the UI output better and lets us achieve more consistency and maintainability across our design systems. (Disclaimer — This concept is still at an early stage. Not every type of layout will benefit from this system so mix and match as you see fit).

The demo

In the video below, I’ve put together a proof-of-concept flex grid layout to showcase the awesomeness of Stacks. It’s an artboard that mirrors the structure of a basic web page.

Video is roughly edited for speed and stitched together as the plugin evolved. If I had to do it again, I’d make it more concise. Note that the first part of the video is slightly outdated. The Sketch file has since been corrected so that symbol replacement no longer unpredictably resizes the space of the module that was replaced.

While still in early exploratory stages, the following functionality is baked into the template:

  • Desktop to mobile in a few clicks.

The Sketch File

Here it is. Feel free to improve it in any way and let me know.
*IMPORTANT* — The file will NOT work unless you have the latest release of Auto Layout with Stacks Support (.0.2.0 as of this writing).

https://cl.ly/2v2I373P2E1f

Some final thoughts

I hope that was useful to some folks. I know I’ll be exploring the possibilities of Autolayout and Stacks deeper. As of this version, I’ve noticed a few small quirks with the math rounding, but hopefully those will get sorted out in time. Amongst some of the requests I’ve suggested to the devs, I think these could be valuable.

  • The ability to add a background to a stacked group (parent row of the columns) without affecting the stack logic. In HTML/CSS, this would simply be done at the <group> or “div” level, but Sketch does not allow a way to do that as of now.
    There is an approach to doing this right now that involves grouping a background layer with a stacked group and pinning the bg to top/left/ 100% width & height, and while the background grows to accommodate the content, it does not shrink when the content is removed. I believe the shrinking is already on the team’s TO-DO list.

Well, that’s all I got! Just wanted to give a shoutout to the the team at Anima once again. They are incredibly talented, responsive, and inviting so please be sure to support their hard work! Join their Facebook page.

If you have any questions or (nice!) comments, please feel free to post below or reach out on Twitter.

Design + Sketch

The best collection of articles, tips, tutorials, and stories on designing and prototyping with Sketch and beyond

Alan Roy

Written by

Alan Roy

Product Designer at StackRox. SF Bay Area.

Design + Sketch

The best collection of articles, tips, tutorials, and stories on designing and prototyping with Sketch and beyond

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade