With svg animation
Claude Code skills for SvelteKit, canvas, drag-and-drop, and SVG animation
npx -y skills add robcsaszar/frontend-kit --skill with-svg-animationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 26 days oldThe repository was created 26 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Expert guidance on performant SVG animation techniques. Use when animating SVGs, stroke draw effects, path morphing, clip-path animations, SVG motion, hover effects, or choosing between CSS/GSAP/anime.js for SVG animation. Not for raster/canvas animation or non-SVG DOM transitions — see with-canvas for those.
SKILL.md
7.6 KB, as published. Nobody here has run it
SVG Animation — Expert Guidance
When animating SVGs, choose the right tool for the job and follow performance best practices. This skill helps you pick the approach, write performant code, and handle accessibility.
Approach Selection
Pick based on what each tool can structurally do, not a feature checklist: CSS can't auto-match vertex counts or detect subpaths the way GSAP's DrawSVG/MorphSVG plugins do, which is why a stroke-draw or morph that works on a simple icon silently breaks on a multi-subpath one in CSS-only setups.
Use CSS-only when:
- Simple state transitions (hover, focus, active)
- Stroke draw effects on single paths
- Clip-path reveals with fixed shapes (polygon, circle, ellipse)
- Opacity/transform-based entrance animations
- You need zero JS dependencies
Use GSAP when:
- Complex timelines with sequenced/staggered animations
- ScrollTrigger integration needed
- DrawSVG plugin for stroke animation (handles subpaths)
- MorphSVG for path morphing (auto vertex matching)
- CustomEase/CustomBounce for advanced easing
- Cross-browser consistency is critical
Use anime.js when:
- Lightweight morphing (
dattribute animation) - Organic blob/shape transitions
- You want a smaller bundle than GSAP
- Timeline features without GSAP's full weight
Use Web Animations API (WAAPI) when:
- Modern browser targets only
- Transform/opacity animations
- You want native performance without libraries
Performance Rules
-
Only animate compositable properties:
transformandopacityrun on the GPU compositor. Animatingwidth,height,top,left,d,points, orviewBoxtriggers layout/paint — use sparingly. -
will-changeusage: Apply only to elements about to animate, remove after. Never blanket-applywill-change: transformto all SVG elements. -
Batch DOM reads/writes: When using
getTotalLength()orgetBBox(), read all values first, then apply all changes. Interleaving reads/writes causes layout thrashing. -
Prefer
<use>sparingly in animated SVGs: Cloned elements with<use>can cause unexpected paint invalidation during animation. -
SVG vs CSS transforms: SVG
transformattribute uses a different coordinate system than CSStransform. For consistency, prefer CSS transforms withtransform-originset explicitly (SVG default origin is0 0, not center). -
Frame budget: Keep animations under 16ms/frame. Complex path morphing on many elements simultaneously will drop frames — stagger or reduce element count.
Stroke Animation (Draw Effect)
The classic "drawing" effect uses stroke-dasharray and stroke-dashoffset.
Pattern:
- Get path length via
getTotalLength() - Set
stroke-dasharrayto total length (one dash = full path) - Animate
stroke-dashoffsetfrom total length → 0 (draws on) or 0 → total length (erases)
CSS-only approach — set dasharray/dashoffset in CSS, animate with @keyframes or transition on class toggle. Works when path length is known or set via inline style from JS on load.
GSAP approach — use DrawSVG plugin for subpath control (drawSVG: "20% 80%"), auto-handles length calculation, supports reverse and partial draws.
Multi-stroke / duotone — layer two <path> copies with different colors and stagger their draw timing for a highlight-trail effect.
MANDATORY READ references/techniques.md before writing stroke-draw, clip-path, or morph code — full worked examples for every approach above. Do NOT load it for approach-selection questions; the tables above already answer those.
Clip-Path Animation
Two approaches: CSS clip-path property or SVG <clipPath> element.
CSS clip-path:
- Animate between
polygon(),circle(),ellipse(), orinset()shapes - Shapes must have the same number of vertices for smooth interpolation
- Use
transition: clip-path 0.6s easefor hover states - Great for reveal/unreveal effects
SVG <clipPath>:
- Reference with
clip-path: url(#clipId) - Animate the shapes inside the
<clipPath>element - Can animate
<circle>,<rect>,<path>within the clip - Use
gradientTransformon<linearGradient>inside clips for sweep effects
Key gotcha: CSS clip-path with polygon() doesn't interpolate to/from none — always transition between shapes with the same vertex count.
Path Morphing
Morphing between two <path> d attributes requires matching vertex counts and winding order — manual and anime.js approaches need pre-matched point counts; GSAP MorphSVG handles mismatched vertex counts automatically and supports shapeIndex for controlling morph direction.
See references/techniques.md items 8–10 for worked code (anime.js morph, organic blob cycling, GSAP MorphSVG).
Timing & Easing
- Elastic easing (
easeOutElastic,easeInOutElastic) — organic, bouncy feel for blob morphs and playful UI - Bounce — use GSAP's
CustomBouncefor squash-and-stretch; pairs well withscaleYcompression at impact - Stagger —
stagger: 0.05(GSAP) or manualanimation-delayfor sequential element reveals - Timeline sequencing — chain animations with labels/offsets; overlap slightly for fluid motion (
"-=0.2"in GSAP) - Duration guidelines: micro-interactions 150-300ms, state transitions 300-600ms, complex morphs 600-1200ms, decorative loops 2-6s
Accessibility
prefers-reduced-motion:
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
In JS, check window.matchMedia('(prefers-reduced-motion: reduce)').matches before initializing animations. Provide instant state changes instead.
Decorative SVGs: Add aria-hidden="true" and role="presentation". Don't animate SVGs that convey meaning without providing a static fallback.
Flashing: Never animate opacity or color faster than 3 flashes/second (WCAG 2.3.1).
NEVER
- NEVER blanket-apply
will-change: transformto all SVG elements — Instead: apply only to elements about to animate, remove after. Why: unusedwill-changehints waste GPU memory and can hurt performance instead of helping it. - NEVER expect CSS
clip-pathto interpolate to/fromnone— Instead: always transition between shapes with the same vertex count (polygon()topolygon(), notpolygon()tonone). Why: browsers can't smoothly interpolate a shape that doesn't exist; the animation jumps instead of transitioning. - NEVER animate
width,height,d,points, orviewBoxfor the main motion of a frequent/looping animation — Instead: animatetransformandopacity, which run on the GPU compositor. Why: the others trigger layout/paint on every frame and will drop frames under load.
Quick Reference
| Technique | CSS-only | GSAP | anime.js |
|---|---|---|---|
| Stroke draw | ✅ (known length) | ✅ DrawSVG | ✅ strokeDashoffset |
| Clip-path reveal | ✅ polygon/circle | ✅ | ❌ |
| Path morph | ❌ | ✅ MorphSVG | ✅ (same vertices) |
| Squash & stretch | ✅ (basic) | ✅ CustomBounce | ✅ |
| Stagger | ✅ (delay) | ✅ stagger | ✅ stagger |
| Scroll-linked | ❌ | ✅ ScrollTrigger | ❌ |