How to Create Interactive Design with a Nested Component in Sketch

Anima Animations for Sketch — Tutorial & Freebie

Anima App
Anima App
Jul 31, 2018 · 4 min read

Anima (was Timeline) is a tool for interaction design, right inside Sketch.
On this post we’ll explore the key components of Anima Interaction Editor.

Update: Timeline is now part of Anima Toolkit — Allowing designers to create Responsive and Interactive High-Fidelity Prototypes, all inside Sketch

In the last tutorial we have demonstrated a basic interaction (link here if you haven’t seen it). In this tutorial we’ll create an interaction which combines a nested component.

Image for post
Image for post

First, if you don’t have Anima plugin download it here👈
Then, you can download the Sketch file here👈

On this tutorial the hamburger menu is the nested component, because it has its own mini animation when clicking it.

Nested components allows you to have one interaction inside another. This behavior is similar to Nested Symbols in Sketch. It is recommended that a Nested Component will also be a Sketch Symbol.

Let’s get started!

Create the Nested Component

Best practice is to have nested component as a symbol.
Select menu_group and make it a symbol. Now select your new symbol, and click Prototype Tab > Interaction > ‘Create’ in the plugin panel for Interaction Editor.

Image for post
Image for post
Select symbol and click Prototype Tab > Interaction > Create for Interaction Editor

Now, we’ll add some states and actions to create this behavior:

Image for post
Image for post
Here’s how the nested menu should behave

Now add a Click action that will animate the menu hamburger icon into an X sign. To do that, rotate the top line by 45°, and the bottom one to (-45°), and align each one to the center.
Hide the middle line by setting opacity to 0 (or click the hide icon on the layer list).

Image for post
Image for post
Our final states

Between the two states, add one more state where the black circle is shrinking, to make it feel like a camera. We’ll use a Timer to trigger a transition from this middle state.

Image for post
Image for post
Tip: Right click a state to duplicate, delete or change position

Creating the Main Component

After the Nested Component is ready, It’s time to create the Main Component.

Fisrt, insert the interactive Nested Component within the layers, as a symbol instance. Then, select the artboard and click the Prototype Tab > Interaction > ‘Create’ button again to enter Interaction Editor.

Image for post
Image for post

Now we’re going to use a Hover animation when the menu is open. The yellow rectangles will shrink to the right when the mouse is in, and open again when the mouse is out.

First define the click action when menu is open and close. You don’t need to edit the menu since it’s already a nested component. Make sure you define transitions to both directions.

Image for post
Image for post
Define First 2 states: click action on the hamburger menu

After that define each state of the open menu: Mouse in and out of each Category.

Image for post
Image for post
Mouse in & out from each state and back to open menu state
Image for post
Image for post
Here’s how it should look at the end

In this example we didn’t change any of the Transitions durations or the Curves default, in order to keep it simple. But You can definitely do that.

Run it

Once you’ve set everything up, you can preview the component by clicking Run Component. While running a component, you can click or hover it to see how the component behaves right inside Sketch.

Export Code

Now that the design part is done, click on Export Code.
After a few seconds of upload, a popup with a link to share will appear.

Image for post
Image for post
Export Code result: Interactive component + code options

This is the link for our example: http://bit.ly/menu_sample

That’s all for today!

Image for post
Image for post

What is Anima?

Anima allows designers to create high-fidelity prototypes right inside Sketch, Adobe XD, and Figma and export HTML & CSS in a single click.

Join the discussion or show off your designs on Facebook, Twitter, Slack, Instagram. Or, vote for new features at UserVoice.

Stay creative!
❤️ Anima team

Design + Sketch

The best collection of articles, tips, tutorials, and…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store