17

Using Sketch 3 want to export an icon, the icons themselves are 24x24 but they sit within an area of 32x32.

I've figured out how to do it by combining two different layers one 24x24 and the other 32x32 but it's a tedious process. I need to do this for every single icon.

Is there a faster workflow?

2
  • 1
    can you clarify what you mean by "an area"? A solid color? An artboard? A slice? Or do you just need the final file to be 32x32 with the 24x24 icon within it?
    – spiral
    Dec 4, 2014 at 8:32
  • Hi Ariel, welcome to GDSE and thanks for your question. Please clarify what your problem is, as Spiral asks. If possible, please post an example picture. Thanks! If you want to know more about the site, please see the help center or ping one of us in chat once your reputation is sufficient (20). Keep contributing and enjoy the site!
    – Vincent
    Dec 4, 2014 at 11:22

9 Answers 9

15

Hit A to create an Artboard, select the size (or set your own by clicking the + in the bottom right) and start exporting. No need to create extra layers.

9

It's actually very easy if you know how to do it :)

Suppose you have an icon that is 24x24px and you want the png to be 32x32px. You have to create a slice over the icon. The slice must be 32x32px. Then group the slice and the icon together. Last but not least: click on the slice and in the inspector you will see something like this:

Inspector Window

Make sure you check "Export Group Contents Only". The other options must be unchecked.

This way, you will export a transparent png, even if there isn't a transparent background under the icon.

1
  • I don't have theses options, will be deprecated? I am using Sketch version 56.2 Jul 31, 2019 at 18:38
2

If you want to export only the icon layer (24x24) just drag the layer to the desktop.

1
  • Would be nice. Unfortunately you will not have icons for higher screen resolutions. Jul 21, 2015 at 12:32
1

Use this to export your assets. The issue with Sketch itself and most other plugins is that it neglects invisible layers while exporting. As a result, invisible bounds do not work.

I even tried to decrease a bound's opacity to 0 so to try to trick Sketch into exporting it. But Sketch's native export isn't so naive.

You might see a horde of plugins of Sketch that help in exporting assets for Android easily. They might reduce the steps involved, but it doesn't solve the bounds problem.

This one does.

https://github.com/GeertWille/sketch-export-assets

It allows you to export assets for iOS, Android and Windows for all resolutions while keeping the bounds intact.

Saves all that artboard efforts.

1
  • 1
    Hi Sarthak, could you please explain a bit more what we'll find behind the link you provide and why it answers the question? That way, your answer is still of value in case the link breaks at a later time. Link rot is the main reason we really dislike link-only answers here. Thanks for your effort and keep contributing!
    – Vincent
    Jul 8, 2015 at 13:43
0

This method worked for me: Place the correct size slice layer above the layer your icon is on and make sure they are not grouped.

Hope it helps

enter image description here

0

I spent more time than it would have taken manually to go one by one but I did not give up and found a solution that works well:

  1. Copy all icons you wanna export to a new file
  2. Convert them to symbols
  3. Since they became symbols they will have their own artboards (you just need to double click one of the symbols to get to the symbols page)
  4. When on the symbols page make sure that all symbols are collapsed View > Layer list > Collapse all groups and select them all cmd+A
  5. Now you can go on and select make exportable end export them all
  6. Voila! If you named them properly you'll also have them in neat little folders

hope this helped!

0

I came up with a workaround not involving creating separate artboards. It's a little hacky, but it worked for me. I wanted icons within my design to be exportable in Zeplin. So making new artboards would make it more difficult for developers to find the icons.

So I made the square background 1% opacity with the blend mode "Darken". You can't see it at all. Then I grouped that with the icon and made the group exportable. Super simple.

0

Here's the best workaround I found so far.

Create a rectangle size with the bounds size you want. And instead of just setting the opacity to 1%, also put the rectangle inside a group and set the opacity of the group to 1%. Even though now the opacity is 1% of 1%, and thus invisible to RGB, Sketch recognizes it as bounds.

Group the whole thing and set the group to be exportable.

0

This is what I do to create a bounds/boundary that will ensure the desired size of the export. As the bottom layer in your symbol or group draw a rectangle to the size of the desired size of the bounds/boundary of the exported asset. Set the border to .1 width and #FFFFFF color set to 1% opacity. Then set the opacity of the rectangle itself to 20% (below that and Sketch will stop recognizing it as the bounds of your export), then create a layer style so you can just apply it to other bounding rectangles in the future.

This works in Sketch 66.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.