@ericrisco/rsc 1.0.27 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +22 -4
  2. package/manifest.json +230 -2
  3. package/package.json +1 -1
  4. package/scripts/detect-repo.js +27 -1
  5. package/scripts/lib/domains.js +3 -2
  6. package/skills/animate/SKILL.md +228 -0
  7. package/skills/animate/evals/cases.yaml +36 -0
  8. package/skills/animate/references/recipes.md +324 -0
  9. package/skills/animate-expo/SKILL.md +281 -0
  10. package/skills/animate-expo/evals/cases.yaml +36 -0
  11. package/skills/animate-expo/references/recipes.md +385 -0
  12. package/skills/animation-vocabulary/SKILL.md +189 -0
  13. package/skills/animation-vocabulary/evals/cases.yaml +31 -0
  14. package/skills/apple-design/SKILL.md +301 -0
  15. package/skills/apple-design/evals/cases.yaml +33 -0
  16. package/skills/ask-sonner/SKILL.md +104 -0
  17. package/skills/ask-sonner/evals/cases.yaml +33 -0
  18. package/skills/ask-sonner/references/api.md +64 -0
  19. package/skills/design/SKILL.md +8 -0
  20. package/skills/design/references/motion-and-interaction.md +14 -3
  21. package/skills/design/references/visual-system.md +4 -3
  22. package/skills/design-eng/SKILL.md +724 -0
  23. package/skills/design-eng/evals/cases.yaml +36 -0
  24. package/skills/expo/SKILL.md +6 -0
  25. package/skills/find-animation-opportunities/SKILL.md +150 -0
  26. package/skills/find-animation-opportunities/evals/cases.yaml +31 -0
  27. package/skills/improve-animations/SKILL.md +126 -0
  28. package/skills/improve-animations/evals/cases.yaml +31 -0
  29. package/skills/improve-animations/references/audit.md +115 -0
  30. package/skills/improve-animations/references/plan-template.md +73 -0
  31. package/skills/pick-ui-library/SKILL.md +100 -0
  32. package/skills/pick-ui-library/evals/cases.yaml +33 -0
  33. package/skills/prototype/SKILL.md +113 -0
  34. package/skills/prototype/evals/cases.yaml +31 -0
  35. package/skills/prototype/references/picker.md +197 -0
  36. package/skills/react/SKILL.md +6 -0
  37. package/skills/react-native/SKILL.md +5 -0
  38. package/skills/review-animations/SKILL.md +137 -0
  39. package/skills/review-animations/evals/cases.yaml +34 -0
  40. package/skills/review-animations/references/standards.md +187 -0
  41. package/skills/review-animations/scripts/verify.sh +164 -0
  42. package/skills/swift-ios/SKILL.md +7 -0
  43. package/skills/write-swift/SKILL.md +413 -0
  44. package/skills/write-swift/evals/cases.yaml +36 -0
@@ -0,0 +1,228 @@
1
+ ---
2
+ name: animate
3
+ description: "Build a web animation: whether it should animate at all, the purpose, the tool, the properties, the easing curve, the duration, interruption and exit. Writes the CSS or Motion code for dropdowns, modals, toasts, tooltips, accordions, press feedback, stagger and scroll reveals. Use to animate something or make a component feel alive."
4
+ tags: [motion, animation, css, transitions, ui]
5
+ recommends: [review-animations, pick-ui-library, apple-design]
6
+ profiles: [full]
7
+ origin: emilkowalski (MIT, adapted)
8
+ ---
9
+
10
+ # Building Animations
11
+
12
+ > **SDD gate.** If this fired on a **new, non-trivial feature or behaviour change** and there is
13
+ > **no approved spec + plan** under `02-DOCS/wiki/sdd/`, hand off to `../specify/SKILL.md` first —
14
+ > it runs brainstorm → spec → plan → tasks before any code, then routes back here once the plan is
15
+ > approved. Build straight from here only for a genuinely one-line / low-risk change, or a bug fix
16
+ > restoring intended behaviour. Method: `../sdd/SKILL.md`.
17
+
18
+ **Hand-offs.** The **visual system** — palette, type scale, spacing, brand grounding, landing
19
+ composition — is `../design/SKILL.md`'s; this skill only sets motion. **React Native / Expo** motion
20
+ is `../animate-expo/SKILL.md`'s: no hover, two runtimes, gestures as the baseline. **Gesture physics**
21
+ — velocity handoff, momentum projection, rubber-banding, translucent materials — is
22
+ `../apple-design/SKILL.md`'s. Reviewing motion someone else wrote is `../review-animations/SKILL.md`'s.
23
+ The countable half of the bar below is executable: `../review-animations/scripts/verify.sh` flags
24
+ `transition: all`, a `scale(0)` entrance, `ease-in` on UI, a centered popover origin, and motion with
25
+ no reduced-motion guard. Run it before you claim the animation is done.
26
+
27
+ A construction skill. It does ONE thing: turn a request for motion into an implementation that would survive a strict review. It does not audit a codebase (that's `improve-animations`), critique a diff (that's `review-animations`), hunt for places that could animate (that's `find-animation-opportunities`), or build for React Native (that's `animate-expo`).
28
+
29
+ ## Operating Posture
30
+
31
+ You are a senior design engineer building the animation yourself. The bar is Emil Kowalski's animation philosophy — the same bar `review-animations` enforces. Write it so it passes that review the first time.
32
+
33
+ Two failure modes, and the first is worse:
34
+
35
+ 1. **Animating something that shouldn't animate.** The gate below exists to produce zero lines of code sometimes. That's a success, not a dodge.
36
+ 2. **Animating the right thing with the wrong ingredients** — `ease-in` on an entrance, `scale(0)`, keyframes on a toast, a duration that makes a dropdown feel sluggish.
37
+
38
+ Never present motion options as a menu. Make the call, state the reasoning in one line, write the code.
39
+
40
+ ## Hard Rules
41
+
42
+ 1. **Run the sequence in order.** Steps 1 and 2 gate everything. Don't reach for a curve before you know whether it animates at all.
43
+ 2. **No approximated values.** Every curve, duration, and spring config comes from the tables below. Never invent `cubic-bezier(0.4, 0, 0.2, 1)` because it looks familiar.
44
+ 3. **Extend the codebase's tokens, don't fork them.** If `--ease-out` or a duration scale already exists, use it. Adding a parallel system is a defect.
45
+ 4. **Reduced motion and hover gating ship with the animation**, not as a follow-up.
46
+ 5. **Cheapest tool that works.** Don't install a motion library for a fade.
47
+
48
+ ## The Build Sequence
49
+
50
+ ### 1. Should this animate at all?
51
+
52
+ | Frequency | Decision |
53
+ | --- | --- |
54
+ | 100+ times/day (keyboard shortcuts, command palette toggle) | **No animation. Ever.** Stop here. |
55
+ | Tens of times/day (hover effects, list navigation) | Near-imperceptible only — fast and subtle, or nothing |
56
+ | Occasional (modals, drawers, toasts) | Standard animation |
57
+ | Rare / first-time (onboarding, success, celebration) | The delight budget lives here |
58
+
59
+ **Keyboard-initiated actions are a disqualifier, not a judgment call.** Raycast has no open/close animation — that is correct for something opened hundreds of times a day.
60
+
61
+ If the request fails this gate, say so plainly and don't write the animation. Offer the non-motion alternative (instant state change, a static affordance) instead.
62
+
63
+ ### 2. What is the purpose?
64
+
65
+ Name it in one of these words before continuing:
66
+
67
+ - **Feedback** — confirming the interface heard the user
68
+ - **Spatial consistency** — showing where something came from or went
69
+ - **State indication** — making a state change legible
70
+ - **Preventing a jarring change** — bridging content that would otherwise teleport
71
+ - **Explanation** — demonstrating how something works (marketing/onboarding only)
72
+ - **Delight** — allowed *only* at the rare/first-time tier
73
+
74
+ Can't name it? Don't build it. "It looks cool" on a frequently-seen element is a reason to stop.
75
+
76
+ Also check **function**: data the user is reading or acting on should not move for style. A decorative mouse-tracking effect belongs on a marketing page, not on a graph in a banking app.
77
+
78
+ ### 3. Pick the tool — cheapest that works
79
+
80
+ Walk down; stop at the first that fits.
81
+
82
+ | Need | Tool |
83
+ | --- | --- |
84
+ | Hover, press, color, a state toggle you control with a class or attribute | **CSS transition** |
85
+ | Entry animation on mount, no JS state | **CSS `@starting-style`** |
86
+ | Predetermined motion that must stay smooth while the page is busy loading | **CSS animation** (runs off the main thread) |
87
+ | Programmatic control with CSS performance, no library | **WAAPI** (`element.animate()`) |
88
+ | Springs, layout animations, exit animations, gesture-driven values | **Motion** (`motion.dev`) |
89
+
90
+ CSS animations beat JS under load — they run off the main thread, while `requestAnimationFrame`-based animation drops frames while the browser loads, scripts, or paints. Use CSS for predetermined motion, JS for dynamic and interruptible motion.
91
+
92
+ If the task needs a *component* rather than an animation — a toast, a drawer, a command menu, a dropdown — stop and invoke `pick-ui-library`. Hand-rolling those is how you end up with a `<div>` dropdown and no focus management.
93
+
94
+ ### 4. Pick the properties
95
+
96
+ - **`transform` and `opacity` only.** They skip layout and paint and run on the GPU. `width`/`height`/`margin`/`padding`/`top`/`left` trigger all three. (`clip-path` is the sanctioned fourth — see [references/recipes.md](references/recipes.md). `height` is tolerated only for accordions, where there's no transform equivalent.)
97
+ - **Never `scale(0)`.** Start from `scale(0.9–0.97)` + `opacity: 0`. Nothing in the real world appears from nothing.
98
+ - **`transform-origin` at the trigger** for popovers, dropdowns, menus, tooltips — `var(--transform-origin)` in Base UI. **Modals are exempt**; they're not anchored to a trigger, so they stay centered.
99
+ - **Percentages in `translate()`** are relative to the element's own size — `translateY(100%)` moves by its own height whatever the content. Prefer over hardcoded pixels.
100
+ - **In Motion, use the full transform string.** `x`/`y`/`scale` shorthands are not hardware-accelerated and drop frames under load:
101
+
102
+ ```jsx
103
+ <motion.div animate={{ x: 100 }} /> // drops frames under load
104
+ <motion.div animate={{ transform: "translateX(100px)" }} /> // hardware accelerated
105
+ ```
106
+
107
+ - **Never drive a child's transform from a CSS variable on the parent** — it recalculates styles for every child. Set `transform` on the element directly.
108
+
109
+ ### 5. Easing and duration — or a spring
110
+
111
+ **Easing**, in decision order:
112
+
113
+ | Situation | Easing |
114
+ | --- | --- |
115
+ | Entering or exiting | `ease-out` |
116
+ | Moving / morphing on screen | `ease-in-out` |
117
+ | Hover / color change | `ease` |
118
+ | Constant motion (marquee, progress) | `linear` |
119
+ | Default | `ease-out` |
120
+
121
+ **Never `ease-in` on UI.** It starts slow, delaying the exact moment the user is watching. `ease-out` at 200ms *feels* faster than `ease-in` at 200ms.
122
+
123
+ Built-in CSS easings are too weak. Use these:
124
+
125
+ ```css
126
+ --ease-out: cubic-bezier(0.23, 1, 0.32, 1); /* strong ease-out for UI */
127
+ --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); /* strong ease-in-out for on-screen movement */
128
+ --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); /* iOS-like drawer curve (Ionic) */
129
+ ```
130
+
131
+ Need a curve that isn't here? Take it from [easing.dev](https://easing.dev/) or [easings.co](https://easings.co/). Don't hand-roll one.
132
+
133
+ **Duration:**
134
+
135
+ | Element | Duration |
136
+ | --- | --- |
137
+ | Button press feedback | 100–160ms |
138
+ | Tooltips, small popovers | 125–200ms |
139
+ | Dropdowns, selects | 150–250ms |
140
+ | Modals, drawers | 200–500ms |
141
+ | Marketing / explanatory | Can be longer |
142
+
143
+ **UI animations stay under 300ms.** A 180ms dropdown feels more responsive than a 400ms one.
144
+
145
+ **Reach for a spring instead** when the motion is drag with momentum, an element that should feel alive, a gesture the user can interrupt or reverse, or decorative mouse-tracking:
146
+
147
+ ```js
148
+ { type: "spring", duration: 0.5, bounce: 0.2 } // Apple-style — easier to reason about
149
+ { type: "spring", mass: 1, stiffness: 100, damping: 10 } // traditional physics — more control
150
+ ```
151
+
152
+ Keep bounce at 0.1–0.3, and avoid bounce in most UI — reserve it for drag-to-dismiss and playful interactions.
153
+
154
+ ### 6. Interruption and exit
155
+
156
+ - **Transitions, not keyframes, for anything triggered rapidly** — toasts, toggles, anything a user can fire twice in a second. Transitions retarget from the current value; keyframes restart from zero.
157
+ - **Springs for gestures**, because they carry velocity through an interruption.
158
+ - **Exit the way it entered.** A toast that slides in from the bottom leaves through the bottom. Symmetric paths are what make swipe-to-dismiss feel obvious.
159
+ - **Asymmetric timing where the user is deciding.** Slow on the deliberate phase (a hold-to-confirm press: 2s linear), snappy on the system response (release: 200ms ease-out).
160
+
161
+ ### 7. Reduced motion and pointer gating
162
+
163
+ Ships with the animation, every time.
164
+
165
+ ```css
166
+ @media (prefers-reduced-motion: reduce) {
167
+ .element { animation: fade 0.2s ease; } /* keep opacity/color, drop transform-based motion */
168
+ }
169
+
170
+ @media (hover: hover) and (pointer: fine) {
171
+ .element:hover { transform: scale(1.05); } /* touch fires false hovers on tap */
172
+ }
173
+ ```
174
+
175
+ ```jsx
176
+ const reduce = useReducedMotion();
177
+ const closedX = reduce ? 0 : '-100%';
178
+ ```
179
+
180
+ Reduced motion means **fewer and gentler** animations, not zero — keep transitions that aid comprehension, remove movement and position changes.
181
+
182
+ ## Recipes
183
+
184
+ For ready-to-build implementations of the common cases — button press, dropdown, tooltip, modal, drawer, toast, accordion, stagger, hold-to-confirm, tab indicator, scroll reveal, drag-to-dismiss — see [references/recipes.md](references/recipes.md). Load it whenever the request matches one of those components; start from the recipe rather than from a blank file.
185
+
186
+ ## Never Ship
187
+
188
+ Self-check before you finish. Each of these is an automatic block in `review-animations`:
189
+
190
+ | Never | Instead |
191
+ | --- | --- |
192
+ | `transition: all` | Name the exact properties |
193
+ | `transform: scale(0)` entrance | `scale(0.95)` + `opacity: 0` |
194
+ | `ease-in` on a UI element | `ease-out` or a strong custom curve |
195
+ | Built-in `ease-out` on a deliberate animation | `cubic-bezier(0.23, 1, 0.32, 1)` |
196
+ | Animation on a keyboard shortcut or 100+/day action | No animation |
197
+ | UI duration over 300ms with no reason | 150–250ms |
198
+ | `transform-origin: center` on a trigger-anchored popover | `var(--transform-origin)` (modals exempt) |
199
+ | Keyframes on toasts, toggles, rapidly-triggered elements | CSS transitions |
200
+ | Animating `width`/`height`/`margin`/`padding`/`top`/`left` | `transform` / `opacity` |
201
+ | Motion `x`/`y`/`scale` props under load | Full `transform` string |
202
+ | Ungated `:hover` motion | `@media (hover: hover) and (pointer: fine)` |
203
+ | Missing `prefers-reduced-motion` | Gentler variant, not zero |
204
+ | Everything entering at once | 30–80ms stagger |
205
+
206
+ ## Output
207
+
208
+ Write the code. Then, in at most a few lines:
209
+
210
+ - **The gate result** — frequency tier and the named purpose. If something in the request was rejected, say which and why.
211
+ - **The ingredients** — tool, properties, curve, duration or spring config, in one line each.
212
+ - **What to feel-check** — if the result depends on feel you can't judge from code (a crossfade, a spring's bounce, the opacity/height balance in an entering list), say so and point at the check: play it at 2–5× duration or in the DevTools animation inspector, step it frame by frame, test gestures on a real device, and look again the next day with fresh eyes.
213
+
214
+ Don't pad this into a report. The code is the deliverable.
215
+
216
+ ## Tone
217
+
218
+ Opinionated and brief. When the honest answer is "this shouldn't animate," give it — that answer is the reason this skill exists. When feel genuinely can't be settled from code, say so instead of guessing at a value.
219
+
220
+ ---
221
+
222
+ ## Credit
223
+
224
+ Adapted for the rsc catalog from **[emilkowalski/skills](https://github.com/emilkowalski/skills)**
225
+ (MIT, commit `d23d7f8`) by Emil Kowalski — the design-engineering and animation philosophy behind
226
+ [Sonner](https://sonner.emilkowal.ski), [Vaul](https://vaul.emilkowal.ski) and
227
+ [animations.dev](https://animations.dev). The craft bar here is his; the routing, gates and evals
228
+ that make it an rsc skill are not. Nothing in this body is a substitute for his course.
@@ -0,0 +1,36 @@
1
+ skill: animate
2
+
3
+ should_trigger:
4
+ - prompt: "Animate this dropdown so it opens smoothly — pick the right easing and duration."
5
+ why: "A build request for a named component's motion: the skill's core use case."
6
+ - prompt: "Add a transition when the modal opens and closes so it doesn't just pop in."
7
+ why: "Building an enter/exit animation, including the exit path the skill insists is symmetric."
8
+ - prompt: "Make this button feel responsive when you press it."
9
+ why: "Press feedback is a recipe in this skill; 'feel responsive' is its vocabulary."
10
+ - prompt: "I want a hold-to-delete button where the fill animates while you hold it."
11
+ why: "Hold-to-confirm is an explicit recipe (clip-path, 2s linear press, snappy release)."
12
+ - prompt: "Add motion to this toast so it slides in from the bottom and can be swiped away."
13
+ why: "Toast motion with a gesture: transitions over keyframes, symmetric exit, velocity dismissal."
14
+ - prompt: "Make this list of cards feel alive when the page loads."
15
+ why: "'Feel alive' is named in the description; the answer is a stagger, or a refusal if the frequency tier is wrong."
16
+
17
+ should_not_trigger:
18
+ - prompt: "Review the animations in this pull request and tell me what's wrong with them."
19
+ route_to: "review-animations"
20
+ why: "Critiquing existing motion, not building it."
21
+ - prompt: "Animate this bottom sheet in our Expo app so the drag feels native on Android."
22
+ route_to: "animate-expo"
23
+ why: "React Native / Expo motion: different runtime, different tools, no hover."
24
+ - prompt: "What could be animated in this dashboard? I don't know where motion would help."
25
+ route_to: "find-animation-opportunities"
26
+ why: "Nothing has been chosen yet; this is a search, not a build."
27
+ - prompt: "What's the term for when a popover grows out of the button you clicked?"
28
+ route_to: "animation-vocabulary"
29
+ why: "A naming question, not an implementation."
30
+ - prompt: "Choose the color palette and spacing scale for this landing page."
31
+ route_to: "design"
32
+ why: "Visual system, no motion involved."
33
+
34
+ capability:
35
+ - scenario: "User asks: 'animate the command palette so it fades in when you hit Cmd+K'."
36
+ expect: "Refuses the animation on frequency grounds — a keyboard-initiated, 100+/day action gets no motion — says so plainly, and offers the instant state change instead. Producing zero lines of animation code here is the correct outcome."
@@ -0,0 +1,324 @@
1
+ # Animation Recipes
2
+
3
+ Ready-to-build implementations for the cases that come up most. Start from the recipe, then adapt — don't rebuild from scratch.
4
+
5
+ Curves are the `--ease-out`, `--ease-in-out`, and `--ease-drawer` tokens defined in SKILL.md.
6
+
7
+ ---
8
+
9
+ ## Button press
10
+
11
+ Any pressable element. Instant feedback that the interface heard the user.
12
+
13
+ ```css
14
+ .button {
15
+ transition: transform 160ms var(--ease-out);
16
+ }
17
+
18
+ .button:active {
19
+ transform: scale(0.97);
20
+ }
21
+ ```
22
+
23
+ `scale()` scales children too — the label and icons come along, which is what makes it read as a physical press.
24
+
25
+ No hover gating needed here: `:active` is a real press on touch. Gate any `:hover` styling separately.
26
+
27
+ ---
28
+
29
+ ## Dropdown, popover, menu, select
30
+
31
+ Scales out of its trigger, not out of thin air.
32
+
33
+ ```css
34
+ .popover {
35
+ transform-origin: var(--transform-origin); /* Base UI supplies this */
36
+ transition:
37
+ opacity 200ms var(--ease-out),
38
+ transform 200ms var(--ease-out);
39
+ }
40
+
41
+ .popover[data-starting-style],
42
+ .popover[data-ending-style] {
43
+ opacity: 0;
44
+ transform: scale(0.95);
45
+ }
46
+ ```
47
+
48
+ The `transform-origin` is the whole point — the panel should look like it came out of the thing you clicked.
49
+
50
+ ---
51
+
52
+ ## Tooltip
53
+
54
+ Same shape as a popover, faster, plus the detail most implementations miss.
55
+
56
+ ```css
57
+ .tooltip {
58
+ transform-origin: var(--transform-origin);
59
+ transition:
60
+ transform 125ms var(--ease-out),
61
+ opacity 125ms var(--ease-out);
62
+ }
63
+
64
+ .tooltip[data-starting-style],
65
+ .tooltip[data-ending-style] {
66
+ opacity: 0;
67
+ transform: scale(0.97);
68
+ }
69
+
70
+ /* Once one tooltip is open, neighbours open instantly */
71
+ .tooltip[data-instant] {
72
+ transition-duration: 0ms;
73
+ }
74
+ ```
75
+
76
+ The initial delay prevents accidental activation. After that, skipping both the delay and the animation makes the whole toolbar feel faster.
77
+
78
+ ---
79
+
80
+ ## Modal
81
+
82
+ The one popover that stays centered.
83
+
84
+ ```css
85
+ .modal {
86
+ transform-origin: center; /* exempt — not anchored to a trigger */
87
+ transition:
88
+ opacity 250ms var(--ease-out),
89
+ transform 250ms var(--ease-out);
90
+ }
91
+
92
+ .modal[data-starting-style],
93
+ .modal[data-ending-style] {
94
+ opacity: 0;
95
+ transform: scale(0.96);
96
+ }
97
+
98
+ .backdrop {
99
+ transition: opacity 250ms var(--ease-out);
100
+ }
101
+ ```
102
+
103
+ Animate the backdrop's opacity alongside it so they read as one surface.
104
+
105
+ ---
106
+
107
+ ## Drawer / sheet
108
+
109
+ ```css
110
+ .drawer {
111
+ transform: translateY(0);
112
+ transition: transform 500ms var(--ease-drawer);
113
+ }
114
+
115
+ .drawer[data-closed] {
116
+ transform: translateY(100%);
117
+ }
118
+ ```
119
+
120
+ This is how Vaul hides a drawer before animating it in.
121
+
122
+ Add drag and it becomes a gesture problem — see **Drag to dismiss** below.
123
+
124
+ ---
125
+
126
+ ## Toast
127
+
128
+ ```css
129
+ .toast {
130
+ opacity: 1;
131
+ transform: translateY(0);
132
+ transition:
133
+ opacity 400ms ease,
134
+ transform 400ms ease;
135
+
136
+ @starting-style {
137
+ opacity: 0;
138
+ transform: translateY(100%);
139
+ }
140
+ }
141
+ ```
142
+
143
+ - `ease` rather than `ease-out`, slightly slower than typical UI: Sonner reads as elegant partly because its motion is tuned to the component's personality rather than to the generic UI budget.
144
+ - If `@starting-style` isn't available, fall back to the mount flag:
145
+
146
+ ```jsx
147
+ useEffect(() => { setMounted(true); }, []);
148
+ // <div data-mounted={mounted}>
149
+ ```
150
+
151
+ When toasts stack and the list reflows, the opacity change has to work against the height change. There's no formula for that pair — adjust until it feels right, then check it again the next day.
152
+
153
+ ---
154
+
155
+ ## Accordion / collapse
156
+
157
+ ```css
158
+ .content {
159
+ overflow: hidden;
160
+ transition:
161
+ height 200ms var(--ease-out),
162
+ opacity 200ms var(--ease-out);
163
+ }
164
+ ```
165
+
166
+ Keep it short — this is one of the few animations that costs layout on every frame, so a long duration is expensive as well as sluggish. Measure the content height in JS (or use a headless primitive that supplies it) rather than animating to `auto`.
167
+
168
+ ---
169
+
170
+ ## Stagger a group entrance
171
+
172
+ For a list or grid the user sees occasionally — not for a list they scroll past all day.
173
+
174
+ ```css
175
+ .item {
176
+ opacity: 0;
177
+ transform: translateY(8px);
178
+ animation: fadeIn 300ms var(--ease-out) forwards;
179
+ }
180
+
181
+ .item:nth-child(2) { animation-delay: 50ms; }
182
+ .item:nth-child(3) { animation-delay: 100ms; }
183
+ .item:nth-child(4) { animation-delay: 150ms; }
184
+
185
+ @keyframes fadeIn {
186
+ to {
187
+ opacity: 1;
188
+ transform: translateY(0);
189
+ }
190
+ }
191
+ ```
192
+
193
+ Stagger is decorative — it must never block interaction while it plays.
194
+
195
+ ---
196
+
197
+ ## Hold to confirm
198
+
199
+ For destructive actions where a plain click is too easy to fire by accident.
200
+
201
+ ```css
202
+ .overlay {
203
+ clip-path: inset(0 100% 0 0);
204
+ transition: clip-path 200ms var(--ease-out); /* release: snappy */
205
+ }
206
+
207
+ .button:active .overlay {
208
+ clip-path: inset(0 0 0 0);
209
+ transition: clip-path 2s linear; /* press: slow and deliberate */
210
+ }
211
+
212
+ .button:active {
213
+ transform: scale(0.97);
214
+ }
215
+ ```
216
+
217
+ `linear` is correct here — the fill is a progress indicator, and progress shouldn't ease.
218
+
219
+ ---
220
+
221
+ ## Tab indicator with a color transition
222
+
223
+ Timing individual color transitions across a tab list never quite lands. Clip instead.
224
+
225
+ Duplicate the tab list. Style the copy as the active state — different background, different text color. Clip the copy so only the active tab shows, and animate the clip on change:
226
+
227
+ ```css
228
+ .tabs-active-copy {
229
+ clip-path: inset(0 60% 0 20%); /* driven by the active tab's position */
230
+ transition: clip-path 250ms var(--ease-in-out);
231
+ }
232
+ ```
233
+
234
+ The text and background change together, in perfect sync, because they're one element being revealed rather than two colors being interpolated.
235
+
236
+ ---
237
+
238
+ ## Scroll reveal
239
+
240
+ Marketing surfaces only. Don't do this to functional UI a user visits daily.
241
+
242
+ ```css
243
+ .reveal {
244
+ clip-path: inset(0 0 100% 0);
245
+ transition: clip-path 600ms var(--ease-in-out);
246
+ }
247
+
248
+ .reveal[data-visible] {
249
+ clip-path: inset(0 0 0 0);
250
+ }
251
+ ```
252
+
253
+ Trigger with `IntersectionObserver`, or Motion's `useInView` with `{ once: true, margin: "-100px" }`. Fire it once — re-animating on every scroll-by is an interface fighting its reader.
254
+
255
+ ---
256
+
257
+ ## Drag to dismiss
258
+
259
+ The gesture recipe. Springs, not durations, because the user can reverse mid-motion.
260
+
261
+ ```js
262
+ // Dismiss on a flick, not just on distance
263
+ const timeTaken = Date.now() - dragStartTime.current;
264
+ const velocity = Math.abs(swipeAmount) / timeTaken;
265
+
266
+ if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
267
+ dismiss();
268
+ }
269
+ ```
270
+
271
+ ```js
272
+ // Set transform on the dragged element directly.
273
+ // Driving it through a CSS variable on the parent recalcs styles for every child.
274
+ element.style.transform = `translateY(${distance}px)`;
275
+ ```
276
+
277
+ Four details that separate a good drag from a bad one:
278
+
279
+ - **Pointer capture** once the drag starts, so it continues when the pointer leaves the element's bounds.
280
+ - **Multi-touch protection** — `if (isDragging) return` on new touch points, or switching fingers mid-drag makes the element jump.
281
+ - **Damping past boundaries** — dragging beyond a natural edge moves the element less the further it goes. Real things slow before they stop.
282
+ - **Friction, not a wall** — allow the over-drag with rising resistance rather than refusing it.
283
+
284
+ Settle with a spring so an interrupted drag keeps its velocity:
285
+
286
+ ```js
287
+ { type: "spring", duration: 0.5, bounce: 0.2 }
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Masking a crossfade that won't settle
293
+
294
+ When two states overlap visibly during a transition and no amount of easing or duration tuning fixes it, blur the seam:
295
+
296
+ ```css
297
+ .content {
298
+ transition:
299
+ filter 200ms ease,
300
+ opacity 200ms ease;
301
+ }
302
+
303
+ .content.transitioning {
304
+ filter: blur(2px);
305
+ opacity: 0.7;
306
+ }
307
+ ```
308
+
309
+ Without blur the eye reads two distinct objects swapping. Blur blends them into one perceived transformation. Keep it under 20px — heavy blur is expensive, especially in Safari.
310
+
311
+ ---
312
+
313
+ ## Programmatic, without a library
314
+
315
+ When the motion needs JS control but not a dependency, WAAPI gives you CSS-grade performance:
316
+
317
+ ```js
318
+ element.animate(
319
+ [{ clipPath: 'inset(0 0 100% 0)' }, { clipPath: 'inset(0 0 0 0)' }],
320
+ { duration: 1000, fill: 'forwards', easing: 'cubic-bezier(0.77, 0, 0.175, 1)' }
321
+ );
322
+ ```
323
+
324
+ Hardware-accelerated, interruptible, no bundle cost.