The library
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.