Skip to main content
Solved

Nested component, instance swap and stroke scaling issue


Alina_Trussova

Icon stroke width behaves as expected inside the button (it scales with the canvas). However, as soon as it’s turned into a component and the icon is swapped, the stroke resets to a default value of 2px. The frame size behaves as expected.
Icon is resized using scale tool.

Problem appears both ways:
– creating button from scratch (works), make is a component (does not work).
– creating button component with same anatomy from scratch (does not work). Detach the same component (works).

Creating different sizes with variants for each icon is not an option due to the extensive icon library.

Is this a bug, or what could be causing this issue?

Best answer by tank666

Most likely you need to override the icon stroke weight in each button variant.

View original

23 replies

tank666
  • 4854 replies
  • September 8, 2023

Alina_Trussova

Thanks!
– Icons are constructed properly (flatten, only one vector stroke layer and the same layer names, same properties)
– Also I did try creating a component responsible for size (3 sizes). It exhibits the same behaviour. When used in a button component stroke resizes back to original 2px.

Seems like a component adds additional parameters to the setup, but I can not figure out what and do I even have control over it. Currently it’s seems like a bug to me.
Does anybody have any ideas?


tank666
  • 4854 replies
  • Answer
  • September 8, 2023

Most likely you need to override the icon stroke weight in each button variant.


Alina_Trussova

I see! That’s what I was missing! Highly appreciate your help.


Jay_Flaxman
  • New Member
  • 3 replies
  • November 10, 2023

Surely this is still a bug though? I have the same issue where I’ve created a component in which I’ve added an instance swap property for a nested component that I’ve scaled up. As soon as I try swapping the instance of the nested component, the stroke thickness reverts back to the original. If the original instance is scaled, why would the scale not apply to the swapped instance?


Lucas_del_Rio

This is a bug clearly. Been struggling these paste days with the same issue. Makes no sense honestly.


Alina_Trussova

Hi! I have been testing and noticed that I do not experience this problem anymore even without workaround.
So it looks like the bug is fixed now and maybe latest Figma update will help?


Mads_Hensel_dk

Ran into this problem/bug again today, so I don’t think it’s been fixed yet!


Amy_Martens

This definitely still happens and causes a lot of pain trying to use stroke based icon libraries with a design system built in Figma


  • 2 replies
  • March 26, 2024

Still same issue, If ikon or illustration with stokes in nested level inside a parent component. Stroke will not scale if instance is scaled small or bigger.


y_toku
Figmate
  • Community Support
  • 2294 replies
  • March 27, 2024

Thanks for flagging. I’ve shared this internally, but I can’t guarantee that it will be prioritized. Thank you for your understanding!


  • 2 replies
  • March 29, 2024

Kapture 2024-03-29 at 15.37.37
Here is an example. Figure (Scooter) stroke did not scale correctly when it swapped to another figure (Bike) smaller inside a parent instance.


Matt_Barron

yep can also confirm this with stroke widths not resizing!

Heres a rough test trying to get icons to behave at different sizes with stroke weights. I was trying to get away with not having to do full individual variant icon sets for each size/stroke, but looks like the above issue is at play here…


Fe_Van_de_Vyver

Still an issue july 2024


Also still having issue!!


Robby_Prada_DCT

Still have the same issue in September!


yoursharif

Still have the same issue in September! 🙁


Yeazey
  • 3 replies
  • October 30, 2024

After six months of working on DS and icon Lib we faсed this issue with interactive prototype after changing default instanced icon to different one from same lib.

TLDR: First instance (preffered icon) always keep their setting no matter of what. But swapping this icon to different one and then changing states reset all overrides

Stroke width from nested instance always resets to its default state with any state changes even root component.
For example: default icon 24px, 2px stroke, color #000
button with this icon, with overriden stroke to 1.5px, and color #fff stays the same when static, stays the same if button state changed let say to hover. but if i place this button in card component, and changing card state to hover or changing it density to compact Overriden 1px #fff stroke in button component stay as intended till i change preffered (base) icon to different one from same lib, then icon reset to it default 2px #000


Yeazey
  • 3 replies
  • October 31, 2024

Founded temporary workaround, till Figma support, maybe y_toku look and fix Figma’s nested stroke override hallucinations.

Why i call it hallucination? bc

  1. placeholder icon in nested components always keeps all overrides.
  2. stroke color and width always reset to default only after swap placeholder to new icon.
  3. stroke width override after icon swap always behave as intended only after manually changing value to new one and then changing it to old one (which was specified in first override)

1. Stroke color reset can be fixed thru masking icons and change color of that mask instead of stroke.
2. Stroke width reset can be fixed thru changing stroke width to different then changing it back to desired. for example:
if you have icon library with 2px stroke, and .icon from that library has been overriden in .button component let say to 1.5px. And then you placed .button into .card or any other dynamic component (hover states / variants / compact versions etc)

To avoid stroke width reset,
a) Swap placeholder icons to desired icon in .card > .button
b) Change stroke width from 1.5 to 1 or 2, then change it to 1.5 (i found stroke width variables can help do this quickly)


Nikola_Radovanovic

Don’t scale, change the width and height and then change the stroke width.


George22
  • New Member
  • 2 replies
  • January 21, 2025

you saved me a tons of time man, I was strugling the whole day with it! Thank you!! Scaling doesn’t work guys, do resizing manually (just put the text in border width) and it will work!


S.T
  • New Participant
  • 13 replies
  • February 5, 2025

I just ran into this. Material Symbols doesn’t have this issue. Definitely a bug that needs fixing on strokes.


George22
  • New Member
  • 2 replies
  • February 8, 2025
S.T wrote:

I just ran into this. Material Symbols doesn’t have this issue. Definitely a bug that needs fixing on strokes.

check naming of the layers also, it plays a huge role in this problem, all icons vector layers should be named exactly the same


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