paste this link into your ai. it will know what to do.
Alejandro Alvarez's motion rules for websites — fast, snappy, minimal transitions, hovers, press feedback, scroll reveals, page transitions, menus and overlays, with hard duration caps, one-axis movement and full reduced-motion support. Use when adding or reviewing any animation, transition, hover, reveal, page transition or overlay in HTML/CSS.
Techboi Motion
Motion is a quick confirmation, never a show. If nobody would miss it, delete it.
Recipes (copy-paste CSS/JS): [references/RECIPES.md](references/RECIPES.md). Reveal script: [scripts/reveal.js](scripts/reveal.js). Works with techboi-web-rules (tokens, layers, BEM) and is checked by techboi-web-validation and techboi-website-quality-audit.
1. Decide first
- Should it move at all? Seen many times a day (nav, filters, keyboard actions) → no movement, colour only. Keyboard-triggered actions never animate.
- What is it for? Feedback (hover, press), state change (open/closed), orientation (page change, overlay). "Looks cool" is not a reason.
- Fewest properties. Opacity first. Add a short move only if it explains where something came from.
2. Tokens (the only values allowed)
:root {
--dur-fast: 120ms; /* hover, press, every exit */
--dur: 200ms; /* menus, overlays, accordions */
--dur-slow: 300ms; /* cap for anything answering the user */
--reveal-fade: 300ms; /* scroll reveals: play while the user reads */
--reveal-rise: 400ms;
--curve: ease; /* colour and opacity */
--curve-out: cubic-bezier(0.23, 1, 0.32, 1); /* anything entering or moving */
--stagger: 40ms;
--rise: 48px; /* reveal distance — house style, not a standard */
--shift: 8px; /* overlay distance */
}
/* Movement itself lives inside @media (prefers-reduced-motion: no-preference) */Never hardcode a duration or curve. Never use ease-in (feels slow) or transition: all.
3. Caps — two tiers
⚡ Answering the user (hover, press, menus, overlays, page transitions): ≤ --dur-slow (300ms). 🌊 Playing while reading (scroll reveals, first view): --reveal-* tokens, first view ≤ 1s.
| Thing | Duration | Curve | Movement |
|---|---|---|---|
| Hover: colour, underline, weight | --dur-fast | --curve | none |
Press (:active) | --dur-fast | --curve-out | scale: 0.97 |
| Image hover | --dur | --curve-out | scale ≤ 1.03 |
| Menu / overlay open | --dur | --curve-out | opacity + --shift on ONE axis |
| Menu / overlay close | --dur-fast | --curve-out | opacity (exit is always faster) |
| Accordion | --dur | --curve-out | height (interpolate-size) |
| Scroll reveal | --reveal-fade / --reveal-rise | --curve / --curve-out | opacity + --rise up |
| First view (hero title, pixel fall) | ≤ 1s | --curve-out | opacity + short rise |
| Page transition | old --dur-fast / new --dur | --curve | opacity only; header stays |
| Loops (marquee) | linear | linear | needs pause/stop (WCAG 2.2.2) |
- 🟡 The 300ms cap is industry guidance (Emil Kowalski), not a standard. It applies to the ⚡ tier only.
- A row of reveals (with stagger) finishes within ~600ms.
- Stagger ≤ 5 items ×
--stagger. Never block clicks while it plays.
4. Movement rules
- One axis only. Vertical for reveals and drop-downs; horizontal only for a panel entering from a side edge. Never X and Y together, never diagonal, never rotate.
- Distances are tokens:
--rise(48px) for reveals,--shift(8px) for overlays. Panels from an edge may travel their own width. - Never from
scale(0). Start at0.95+ with opacity. - No bounce, overshoot, parallax or blur on large areas (blur is expensive, and WCAG counts it as motion).
- Animate only
opacity,transform,translate,scale. Colour changes are fine. Neverwidth,height,top,margin(except the accordion height viainterpolate-size). - Transitions over keyframes for anything the user can trigger repeatedly: they reverse mid-way, keyframes restart.
- Popovers grow from their trigger (
transform-originat the trigger). Modals stay centred.
5. Page load and scroll
- Above the fold is never hidden. It's visible at once — it may fade in, but never waits for a script. (Protects LCP.)
- Below the fold reveals once, as it enters, never again on scroll-up. Rows arriving together stagger left to right.
- No JavaScript = everything visible. The script only adds the hidden state.
- Don't hijack scroll. If the wheel is smoothed, any key, pointer or touch stops it at once, and it's off with reduced motion.
6. Page transitions
- Cross-document View Transitions only:
@view-transition { navigation: auto; }. No SPA router, no JS. - Opacity crossfade, old out fast, new in slightly slower. Header (and anything shared) keeps its place.
- Browsers without support just navigate — that is fine.
7. Hover and touch
- Every hover lives in
@media (hover: hover) and (pointer: fine)— nothing sticks after a tap. - Every clickable thing reacts, but with colour/weight/underline first; movement only on images and cards.
8. Reduced motion (always)
- With
prefers-reduced-motion: reduce: nothing moves, grows or slides. Every movement rule sits insideno-preference; page transitions and loops are off, video shows its poster. - Opacity and colour changes may stay (≤
--dur-fast); they help comprehension. - 🟢
[STANDARD]WCAG 2.2.2 Pause, Stop, Hide (Level A): content that moves on its own for more than 5s, next to other content, needs a pause/stop/hide control. - 🟢
[STANDARD]WCAG 2.3.3 Animation from Interactions (Level AAA): motion triggered by interaction can be turned off. Opacity and colour don't count as motion; blur does.
9. Check before shipping
techboi-web-validation→check.shstep 6 flagstransition: all,ease-in, hardcoded durations and--dur*tokens over 300ms (--reveal-*are exempt; one-offs carry anallowed:comment).techboi-website-quality-audit→ WCAG 2.2.2 / 2.3.3, Lighthousenon-composited-animations, CLS (reveals usetransform, so they never shift layout).- By eye: DevTools → Animations panel at 10% speed; then turn on Reduce motion and check that nothing moves.
keep it where your ai can reach it.
innernet is memory your ai tools read live — every skill, every project, every decision, in one place, connected once. save this skill to yours, or publish one of your own as a link like this.