Guides

Shapes & morphing

The 35 Material 3 Expressive shapes, generated from the same polygon math as Android: a line-by-line port of AndroidX graphics-shapes. Any shape morphs into any other on a spring.

The library

circle
square
slanted
arch
fan
arrow
semiCircle
oval
pill
triangle
diamond
clamShell
pentagon
gem
sunny
verySunny
cookie4Sided
cookie6Sided
cookie7Sided
cookie9Sided
cookie12Sided
ghostish
clover4Leaf
clover8Leaf
burst
softBurst
boom
softBoom
flower
puffy
puffyDiamond
pixelCircle
pixelTriangle
bun
heart

Morph on change

Change the shape and it morphs with the M3 default spatial spring (or the one you pass).

SwiftUI
M3EMaterialShape(liked ? .heart : .circle, motion: .fastSpatial).frame(width: 64)

Spin

spinDuration rotates a shape continuously using Core Animation.

SwiftUI
M3EMaterialShape(.softBurst, spinDuration: 20).frame(width: 48)

Clip content to a shape

SwiftUI
Image("avatar").resizable().scaledToFill().frame(width: 56, height: 56).clipShape(M3EShape.cookie9Sided)

Your own polygons

RoundedPolygon and Morph expose the AndroidX shape API in Swift: regular polygons, stars, rectangles, pills, per-vertex rounding and smoothing, normalization and morphing.

SwiftUI
let star = RoundedPolygon.star(numVerticesPerRadius: 5, innerRadius: 0.5, rounding: CornerRounding(radius: 0.1)).normalized()
MorphShape(morph: Morph(M3EShape.circle.polygon, star), progress: t).fill(.purple)

Guidance

  • Use shapes with intent: avatars, image masks, loaders, and to signal state (a heart for a like).
  • One strong shape per area. Many different shapes at once read as noise.
  • Keep text off busy shapes like burst, boom and softBoom; use circle, square or pill behind text.
  • Morph between shapes with a similar footprint for the smoothest transitions.