Skip to main content
Question

Swapping icons in an autolayout component


Goril_Torske

Hello, and thank you for a great app! We are building a lot of components based on autolayout, and have a question regarding swapping icons. It concerns our accordion, where we’d like to use different icons for different headings.

Earlier we could drag an icon into the component’s autolayout. Some blue lines would appear, we could delete the old icon and keep the new one. Now, we can’t make the new icon part of the autolayout, it seems.

Does anyone have any idea how to solve this? Is there a work around?

This topic has been closed for comments

12 replies

tank666
  • 4858 replies
  • February 7, 2022

Icon swapping is the same as before: via the Swap instance or Components (Shift + I) modals, or from the Assets panel, or via the context menu.


Goril_Torske

Many thanks for your quick response! 😊 Our problem is that the icons in the accordion are smaller (width 32px) than the components in our Design System (width 40px). So when we change via Swap instance, the proportions of the icon doesn’t scale correctly.

Usually, I have found the icon in the Assets panel, pulled it in, changed size and either copied it into the autolayout or dragged it into it. But unfortunately, I don’t get this to work anymore.


tank666
  • 4858 replies
  • February 7, 2022

As you can see in your screenshot, your “Accordion with icons Desktop default” is a component instance. You couldn’t add another new object to a component instance before, even if Auto Layout was applied to that instance. All you could do was hide and/or edit the existing objects in the component instance. You are most likely describing inserting an icon into Auto Layout when it was not yet a component instance.

As another way, you can try doing this:

  1. Place an icon from the Assets panel on the canvas.
  2. Resize it.
  3. Cut it out.
  4. Select the instance of the icon in your accordion.
  5. Use the “Paste to replace” function.

Goril_Torske

Many thanks again! 🙏 😊 I’ve followed your 5 steps, but I get “Pasting inside the current selection is not possible”. Do you have any idea what goes wrong?


tank666
  • 4858 replies
  • February 9, 2022

I’m sorry, apparently this function doesn’t work with nested instances in the component instance.

So you can swap nested instances only like this:


Could you show how the wrong scaling happens?


Goril_Torske

Hello again! 😊 When I swap the square icon in the instance with an icon which is lower, the lower one will fill the height of the original icon. It might be that I should have used a different Resizing in the component, though. The icon autolayout is set to “Hug contents” and the “Theory Test” icon (the icon used in the component) is set to Fixed width and Fixed height.


tank666
  • 4858 replies
  • February 9, 2022

Apparently you need to change something in your components. Check out the file I created for you:

Figma – 9 Feb 22

Goril_Torske

Hello again, and many thanks for det artwork! 😀 👏

Do you think you could have a look at mine (and what goes wrong there)? As you can see, our icon and chevron can’t be centered along with the text, in case the heading grows.


tank666
  • 4858 replies
  • February 11, 2022

I added an example to the same file from the link above.


Adam
  • 47 replies
  • February 11, 2022

Place every icon vector within a 40x40px parent frame.
Name every single icon vector the same thing “vector” etc.
Make every single icon vector “scale/scale” constraints within the parent frame.
Your problem should be solved.


Goril_Torske

Many thanks, @tank666 and @Adam! 🤩


  • 0 replies
  • March 16, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings