…so I wrote an article about SVG export settings 😃
You can find the original article on Medium.
However, in efforts to make this information available to readers who have left Medium, I’ll be reposting the contents of the article here.
OG article starts now 👇
SVG Export Settings for Custom CSS Animations in Adobe Illustrator
The right SVG export settings can be tricky to figure out, especially if your goal is to animate it later.
Cue the process of trial and error that totally doesn’t make you want to throw your laptop out the window.
After several attempts at getting Illustrator to generate the most optimally structured code for custom CSS animations, I finally found the settings that work best. Since information on this topic is scarce, I’m sharing what I’ve learned via a handy 13-step guide.
This step-by-step guide is current with Adobe Illustrator Version 23.
To view which version of Illustrator you have, open your program and click the ‘Illustrator CC’ tab located in the top navigation menu. Then, click the ‘About Illustrator…’ option.
A window with some information should pop up.
If you’re running the same version as me, great — you should be able to follow these steps with no problems! Going forward, this method should be compatible with most versions of Illustrator (unless Adobe releases changes that alter settings used here). If you’re running an older version and this guide works, let us know in the response section below.
Alright, now that we’ve got that squared away, let’s take a look at the steps!
The Step-By-Step Roadmap
When following this guide, pay extra attention to Step 8. There are two options available that are dependent on your preferences.
Step 1: Select all graphics on the artboard [shortcut keys:
command ⌘ + aon Mac/
ctrl + a on a PC]. To achieve this without using shortcut keys, find the ‘Select’ tab in the top navigation and choose the ‘All’ option.
Step 2: Click the ‘Object’ tab in the top navigation menu.
Step 3: Click ‘Expand Appearance’. This converts design elements like paths, lines, etc. into editable vector shapes.
Step 4: Click the ‘File’ tab in the top navigation menu.
Step 5: Hover over the ‘Export’ option and click the ‘Export As’ option.
The following window will be displayed. Steps 6 through 9 are to be done in this window.
Step 6: Name your file and choose where you’d like to export the file.
Step 7: Find the ‘Format’ dropdown menu at the bottom of the window and select SVG (svg).
*Step 8: Check the ‘Use Artboard’ option below the Format dropdown menu if you wish to include only the graphics inside your artboard. If you wish to include graphics that extend outside of the artboard, leave this unchecked.
Step 9: Click the ‘Export’ button to continue.
Once clicked, the following window will be displayed. Steps 11 and 12 are to be done in this window.
Step 10: Adjust the settings as follows:
- Styling: Internal CSS
- Font: SVG
- Images: Embed
- Object IDs: Layer Names
- Decimal: 2
- Leave the ‘Minify’ and ‘Responsive’ checkboxes unchecked.
If checked, Illustrator would compress your code by removing any unnecessary characters like white spaces or new lines. This is not an ideal code structure to work with as you would have to separate the code yourself.
Step 11: Click the ‘OK’ button at the bottom right of the window.
Step 12: Locate the file from wherever you saved it. (This was done in step 6.) In my example screenshot you can see that my awesome.svg file was saved to my desktop.
Step 13: Right click the file and open it in your text editor.
And BAM, you now have the most optimal SVG code ready for custom CSS animations!
Now you can begin sifting through the code blocks to identify what is what.
To bring this article full circle, here are three workflow options for finding which part of the graphic belongs to which particular block of code:
Firstly, if your designer named their layers, then this process will be easy. Then,with the file opened up in your editor, search for the layer name and then write a comment above it to label what it is for future reference.
Secondly, if your designer didn’t name their layers, you can name them yourself in Illustrator, save the file and then export. From here, you can follow through with the above paragraph’s comment/label workflow.
Thirdly, if for whatever reason you’re working with unnamed layers, the labelling process will be a bit longer, but still doable. Begin by commenting out code blocks to see which element was removed from the image. Once identified, uncomment the code block and label it with a comment above it. Rinse, wash, repeat.
After that, identify which graphics you want to animate. Then, remove the commented labels for graphics that you will not be animating to reduce file size.
From there, you can start to write the custom CSS animations in between the style tags and add their respective class to the code as you test the animation and move along to the other graphics you want to animate.
Finished Animated SVG Example
Below I’ve included an example of a finished animated SVG that I did for a recent project at Envy Labs.
Did this article help figure out the best SVG export settings for your project? Did you create a really awesome animated SVG? Let me know in the comments section below!
About the Author
Connor Ocampo is a Front-End Developer at Envy Labs, a data-driven web application consultancy with a focus on interactive training and visualization.
Less formal bio: Connor likes @gatsbyjs, burritos and is intermittently existential.
Follow him on Twitter.