Makepad-skills makepad-2.0-animation
git clone https://github.com/ZhangHanDong/makepad-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/ZhangHanDong/makepad-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/makepad-2.0-animation" ~/.claude/skills/zhanghandong-makepad-skills-makepad-2-0-animation && rm -rf "$T"
skills/makepad-2.0-animation/SKILL.mdMakepad 2.0 Animation Skill
Version: makepad-widgets (dev branch) | Last Updated: 2026-03-03
Overview
The Animator system drives
instance() shader variables over time, enabling hover effects, transitions, and looping animations. It uses independent animation tracks called "groups" that run simultaneously.
Documentation
Refer to the local files for detailed documentation:
- Complete Animator API, play types, ease functions, examples./references/animator-reference.md
IMPORTANT: Documentation Completeness Check
Before answering questions, Claude MUST:
- Read the relevant reference file(s) listed above
- If file read fails or file is empty:
- Inform user: "Reference docs incomplete. Still answering based on SKILL.md patterns."
- Still answer based on SKILL.md patterns + built-in knowledge
- If reference file exists, incorporate its content into the answer
Critical: Widget Animator Support
NOT all widgets support
! Adding animator
animator: Animator{...} to an unsupported widget is silently ignored - no error, no animation, nothing happens.
Widgets that SUPPORT Animator
View, SolidView, RoundedView, ScrollXView, ScrollYView, ScrollXYView, Button, ButtonFlat, ButtonFlatter, CheckBox, Toggle, RadioButton, LinkLabel, TextInput
Widgets that DO NOT Support Animator
Label, H1-H4, P, TextBox, Image, Icon, Markdown, Html, Slider, DropDown, Splitter, Hr, Filler
To animate a Label: Wrap it in a View with the animator:
View{ width: Fit height: Fit animator: Animator{ hover: { default: @off off: AnimatorState{ from: {all: Forward {duration: 0.15}} apply: {draw_bg: {hover: 0.0}} } on: AnimatorState{ from: {all: Forward {duration: 0.15}} apply: {draw_bg: {hover: 1.0}} } } } label := Label{text: "Animated via parent"} }
Animator Structure
animator: Animator{ <group_name>: { default: @<state_name> <state_name>: AnimatorState{ from: { ... } ease: <EaseFunction> redraw: true apply: { ... } } <state_name>: AnimatorState{ ... } } <group_name>: { ... } }
Groups
Each group is an independent animation track. Common groups:
| Group | Purpose | Typical States |
|---|---|---|
| Mouse hover in/out | , |
| Keyboard focus | , |
| Toggled/checked state | , |
| Disabled state | , |
| Continuous looping | , |
Multiple groups animate simultaneously without interfering.
The from
Block
fromControls transition timing. Keys are states being transitioned FROM, or
all as catch-all.
// From any state, animate over 0.2 seconds from: {all: Forward {duration: 0.2}} // Instant from any state from: {all: Snap} // Different timing depending on origin from: { all: Forward {duration: 0.1} down: Forward {duration: 0.01} }
Play Types
| Type | Description | Example |
|---|---|---|
| One-shot forward | Hover transitions |
| Instant jump, no animation | Default state initialization |
| Looping animation | Loading spinners |
| Ping-pong loop | Pulsing effects |
| Bounce back and forth | Bouncing animations |
Ease Functions
| Function | Description |
|---|---|
| Constant speed |
/ / | Quadratic easing |
/ / | Cubic easing |
/ / | Quartic easing |
/ / | Quintic easing |
/ / | Sine easing |
/ / | Exponential easing |
/ / | Circular easing |
/ / | Elastic spring |
/ / | Overshoot |
/ / | Bounce |
Usage:
ease: OutCubic in the AnimatorState (optional, defaults to Linear).
The apply
Block
applyTarget values to animate TO. Structure mirrors the widget's shader properties.
// Animate single properties apply: { draw_bg: {hover: 1.0} } // Animate multiple properties apply: { draw_bg: {hover: 1.0 color: #f00} draw_text: {color: #fff} }
CRITICAL: Only
instance() shader variables can be animated. uniform() variables cannot.
Complete Hover Button Example
use mod.prelude.widgets.* let HoverCard = RoundedView{ width: Fill height: Fit padding: 16 new_batch: true cursor: Hand draw_bg +: { instance hover: 0.0 color: mix(#2a2a3d, #3a3a5d, self.hover) border_radius: 8.0 } animator: Animator{ hover: { default: @off off: AnimatorState{ from: {all: Forward {duration: 0.15}} apply: {draw_bg: {hover: 0.0}} } on: AnimatorState{ from: {all: Forward {duration: 0.15}} apply: {draw_bg: {hover: 1.0}} } } } title := Label{text: "Hover me" draw_text.color: #fff} }
Key points:
is REQUIRED for hoverable items with backgroundsnew_batch: true
shows pointer cursor on hovercursor: Hand
declares the animatable variableinstance hover: 0.0
interpolates between colorsmix(color1, color2, self.hover)
Timeline Animation (Keyframes)
For multi-step animations use
timeline():
animator: Animator{ time: { default: @off on: AnimatorState{ from: {all: Loop {duration: 2.0}} apply: { draw_bg: { rotation: timeline(){ snap(0.0) snap(6.28) } } } } } }
Loading Spinner Pattern
let Spinner = View{ width: 40 height: 40 draw_bg +: { instance rotation: 0.0 pixel: fn() { let sdf = Sdf2d.viewport(self.pos * self.rect_size) let cx = self.rect_size.x * 0.5 let cy = self.rect_size.y * 0.5 let r = min(cx, cy) * 0.8 sdf.arc(cx, cy, r, self.rotation, self.rotation + 4.5, 3.0) sdf.stroke(#4488ff, 2.5) return sdf.result } } animator: Animator{ time: { default: @on on: AnimatorState{ from: {all: Loop {duration: 1.0}} apply: { draw_bg: { rotation: timeline(){ snap(0.0) snap(6.28318) } } } } } } }
Animator vs Vector Tween
Makepad has two separate animation systems:
| Feature | (this skill) | (see makepad-2.0-vector) |
|---|---|---|
| Target | Widget shader vars | SVG shape properties (fill, cx, opacity...) |
| Syntax | block | Property value: |
| Triggers | State transitions (hover, focus) | Automatic on render |
| Loop | in | (bool, NOT string!) |
| Use for | UI interactions (hover, click) | SVG/Vector graphic animations |
Use Animator for: Button hover effects, toggle states, loading spinners (shader-based) Use Vector Tween for: SVG path animations, pulsing indicators, moving dots, color transitions
See the
makepad-2.0-vector skill for Tween details.
Best Practices
- Always add
to Views with backgrounds that have hover animationsnew_batch: true - Use
variables for anything you want to animateinstance - Match group names to semantic purposes (hover, focus, active)
- Use Forward for transitions, Snap for instant state changes
- Set
for states that start inactivedefault: @off - Label cannot animate - wrap in View if you need animation on text
- Keep durations short (0.1-0.3s) for hover, longer (0.5-2.0s) for time-based