To mark any layer, group, or Artboard as an exportable layer in Sketch, make sure it is selected, and click the “Make Exportable” button at the bottom of the Inspector.
When a layer has been marked as ‘exportable’, a new view will appear in the place of the button. It‘s here where you can adjust and define the settings for export. Anything you select will be applied when the layer is exported.
Clicking on the add button in the “Export” title will add another scale to your export. The default values will be automatically determined by the previous settings, but this means Sketch will export a different version of the image, as defined.
The export settings apply to any layer or slice, and it enables you to export to multiple sizes, or filetypes, without the need of individually defining them in the Canvas. Here, you will see three main controls. Size, suffix, and format.
You can define the size, or scale in which an element will export, either by entering a value, or selecting one already defined in the pop-up menu.
The default size is ‘1x’, which will export your layer at the actual size it was created. If you’re designing for mobile, you may want to export something at double the size you created it, in this case ‘2x’. There’s no limit to how much you can multiply by, and you can even scale down in the case of ‘0.5x’. If designing for Android devices specifically, then you can export to a custom size.
Aside from just multiplying the scale, you can also export to a particular width, or height. For example, to export a layer from its original size to 128 pixels wide, simply type ‘128w’. ‘128h’ would be used to export to 128 px tall.
To learn everything there is to know about pixel densities, check out Pixel Density, Demystified from Peter Nowell.
The suffix text box works in conjunction with the size control. If you have more than one export scale defined, then at least one suffix is required to append onto the end of the exported file’s name to tell them apart.
Typically, objects exported at a ‘2x’ scale will have the suffix of [email protected] as this meets the naming conventions required by Apple when designing for their operating systems.
The format button allows you to choose which file format you would like to export to via the pop-up menu. File formats are covered in greater detail in their own section.
Exportable Layers or Slices?
Exporting a layer by itself means that no other elements on the Canvas will be exported with it, and its size will be defined by the layer’s bounds. If there’s a layer on top or a background below it, neither of those will be included in the export.
Marking layers as exportable has its uses, but it doesn’t cover all cases. This is where slices can come into effect.
It’s possible to create a slice straight from an exportable layer. Simply click the Slice button in the “Export” title and a new slice layer will be created around the object containing the defined settings.
Layers that have been made exportable will make themselves known in the Layer List, by displaying a small slice icon next to the layer preview.
However, you can directly export any layer, straight from the Layer List without having to make it exportable or defining slices. If you click-and-drag any layer from the Layer List out of the application, Sketch will quickly export it as a PNG. If you hold down the Option key, it’ll export as a PDF instead.
When you want to export your object, you can click the “Export…” button to quickly save it to a location on your computer, or click the Share button to attach to an email, share in a tweet, AirDrop it to a colleague, etc.