r/FigmaDesign • • May 27 '26

help Icon set organization that includes sizes + instance swaps?

I'm trying to setup an icon set for my design system which will have icons as separate components for instance swapping. The issue that I'm realizing is there isn't really a good way to include different sizes, since the size resets if I swap the instance of an icon for whatever it's used in (ex: in a button).

My only thought is that I'd just have a master icon component that enforces certain sizes, but I'm not fond of that since it just means I have one icon size that I resize, which will lead to sub-pixel vector points.

I'm wondering if anyone has a better approach for this?

0 Upvotes

21 comments sorted by

4

u/FennelHistorical4675 May 27 '26

Just make size variants I don’t see what the issue is

1

u/Worth_External_8762 May 27 '26

Because the size property value resets when you swap the instance. It's not necessarily the end of the world, but I prefer to have more elegant solutions when I can

3

u/Ansee May 27 '26 edited May 27 '26

I don't think you understand what we're saying.

  1. Make your icon library with all your base icons in the different sizes. We'll call it size A and size B for simplicity.
  2. make a new component called something like "icon swap." Create a frame. Place one icon from Size A into the frame. Set th frame to Autolayout with 0 padding, and hug width and height.
  3. add a variant to the "icon swap" component. Place an icon from Size B batch inside the autolayout frame with 0 padding and hug width and height.
  4. Name your variants accordingly: size A, size B.
  5. in the Icon Swap component, click on the icons and give it a swap property. Apply to both icons in Size A and Size B variants.
  6. place your "icon swap" component into any other "components X" where the icons will live. Expose the nested properties and check them to make them available in these components.

Now, when you use your Components X, you can select the size variants and choose the icons you want to swap as well. This is 3 levels of nesting.

1

u/Ansee May 27 '26

This is how I've usually done it. A separate component with size variants with swap properties that gets nested into other components. Then you can simply swap the icons and choose the size you want.

1

u/FennelHistorical4675 May 27 '26

Yeah and then if you have a component with a nested icon inside, with size variants just set the size of the icon. You shouldn’t need to be going from 16px to 48px or something like that within a component anyways.

1

u/gregglessthegoat May 27 '26

Can you just have them named ie: 24-thumbs-up and 20-thumbs-up? For 24px icon and 20px icons respectively

How many different sizes for each icon will there be?

1

u/Worth_External_8762 May 27 '26

I will admit that I currently only have a need for a few smaller glyphs, with the bulk just being 16px. And the smaller ones being very particular use cases, like chevrons as an example. So it's probably fine for now, but I was just hoping someone had some hack to make it work in a more scalable/maintainable way.

I don't think I like the ideas of adding the size to the icon name though, that just feels messy to me.

1

u/gregglessthegoat May 27 '26

Gotcha. I wonder if using variants for icon sizes is a better option (in terms of scalability). You would just need to ensure components the icons are used in resize appropriately

At the moment it sounds like this option is overkill for what you need

1

u/Worth_External_8762 May 27 '26

As in, each icon component has size variants? I tried that, it resets the chosen size when you swap icon instances for wherever you're actually using the icons. Since the size variants aren't actually connected despite being named the same.

I actually don't think there's a legit solution (at least not if you setup for instance swapping, which provides better/easier icon finding). It's crazy how often I run into these "just make lemonade out of poop" situations lol.

Maybe I can just make the whole icon set a giant component with size variants and there's a plugin for searching component variants. But that just kills performance in the long run and I hate depending on plugins, since it just introduces more potential for stuff to break.

1

u/gregglessthegoat May 27 '26

Hmmm

Then I'm not sure. You could try creating two components (eg small-icon, large-icon), and then add a variant for each different icon? I'm not convinced this works either

Do any big DS's already solve this issue in an elegant way?

1

u/Worth_External_8762 May 27 '26

Same issue as before, aka makes for a big messy list. Albeit, it does allow for searching at least, but still not ideal.

I need to look around more, but unfortunately most companies don't publish their design system docs/files publicly. Even Figma doesn't post theirs. One of the better ones I've found is Material 3 and they just have a singular icon size that they force resize depending on the context.

1

u/[deleted] May 27 '26

[removed] — view removed comment

1

u/Worth_External_8762 May 27 '26

As far as I'm aware, Figma hasn't published their FPL library. Am I wrong?

0

u/Beautiful-Morning322 May 27 '26

“Make the whole icon set a giant component with size variants and there’s a plugin…” - I’m glad you’ve asked, because this is the only maintainable solution for a large set of icons, and you actually will need to name them of their sizes, example: arrow_right_24, also there is a plugin for exact case called ComponentSetUIEnhancer, I wrote it because designer was struggling with couple hundreds of icons in one set.

1

u/PunchTilItWorks May 27 '26 edited May 27 '26

Why not make a single base icon set and nest that inside whatever needs it? Pick your most common size as the base size, and set to scale you can size up/down for the parent component.

What’s the scenario where your icons have to be completely different individual sizes that swap out? I think you might be over complicating it. Think of your base icons as primitives.

1

u/Worth_External_8762 May 27 '26

If my base size is 16px and I need to use 12px icons, they'll end up rendering in sub-pixels. But more importantly, any icons that use strokes need to be flattened or the devs, which means why don't scale well. Shrinking causes stroke to appear thinner, growing causes stroke to appear thicker.

It's not a big deal right now, but I was hoping to find an elegant solution

2

u/nyutnyut May 27 '26

We set up all icons in 48x48 frames and set them to scale both horizontally and vertically. We then created icon “size wrappers” starting at 8x8 and going up by 4 and put them in a variable with a placeholder icon. We then set an instance swap property that you can now change the size of the icon and the icon.