Vector vs Raster for UI Graphics and Animation: Which to Use
When to use vector or raster graphics in UI and animation: sharpness, file size, rendering cost, textures and photos, and when to combine both.
Core Takeaway
Vector graphics are described by shapes and stay sharp at any size, which makes them ideal for icons, illustrations and UI animation. Raster images are grids of pixels, better for photos, rich textures and painterly art. Many animations combine both: vector for shapes and motion, raster for detail. Choose by content, display size and how much the graphic needs to change.
The difference
A vector graphic stores instructions: a circle here, a curve there, this colour. The renderer draws it at whatever size the screen needs. A raster image stores pixels at one resolution; scale it up and it blurs, scale it down and you waste bytes. SVG is the web's vector format, while PNG, JPEG, WebP and AVIF are raster formats, as MDN's guides describe.
When vector wins
Use vector for:
- Icons, logos and UI shapes that appear at many sizes
- Flat or gradient illustrations
- Anything whose shape animates: morphing, drawing, bending
- Graphics whose colours change with themes or data
When raster wins
Use raster for photos, detailed textures, painted art and complex effects that would need thousands of vector paths. A very detailed vector illustration can be larger and slower to render than an equivalent image.
Combining both
Most production animations mix them. A character can have vector limbs that bend and a raster texture on the clothes. A hero scene can have a raster background and vector UI on top. Provide raster images at the sizes they will display, for 1x, 2x and 3x screens where needed.
Building this in ExodeUI
ExodeUI, which we make, is vector-first and can also place images, so you can keep shapes that animate as vectors and use raster images for photos or textures in the same component.
Key Principles to Remember
- Vector: sharp at any size, ideal for icons, illustrations and motion
- Raster: best for photos, textures and painterly art
- Overly detailed vectors can be heavier than images
- Most good animations combine both
Frequently Asked Questions
Sources
- SVG: Scalable Vector Graphics — MDN Web Docs
- Image file type and format guide — MDN Web Docs