# Motion & microinteractions

> Purposeful animation in interfaces: the four parts of a microinteraction, what motion is for, duration and easing, choreography, loading states, tools, and designing for people who prefer reduced motion.

Web page: https://odeocreative.me/tutorials/ui-design/motion
Author: Hecham Gazhi (https://odeocreative.me)

Track: [UI Design Tutorial](/md/tutorials/ui-design.md)

## Why motion matters

Motion makes interfaces feel alive and understandable. When a panel slides in from the right, you know where it came from and where it will go when closed. When a button gently compresses as you tap it, you know it registered. When a heart bursts after you like a photo, you feel a moment of delight.

But motion is also easy to overdo. Slow, flashy or unnecessary animations make products feel sluggish and can make some people physically unwell. Good motion is **purposeful, quick and subtle**.

## Microinteractions

A **microinteraction** is a small, contained moment built around a single task: liking a post, toggling a setting, pulling to refresh, setting an alarm. Dan Saffer described four parts:

| Part | Question | Example: a 'Like' button |
| --- | --- | --- |
| Trigger | What starts it? | User taps the heart |
| Rules | What happens? | The post is liked; the count increases by one |
| Feedback | How does the user know? | The heart fills red with a small pop, the number updates |
| Loops & modes | What happens over time or in special cases? | Tapping again unlikes; offline, the like is saved and synced later |

## What motion is for

### Feedback

Confirm that an action was received: button press states, a checkmark after saving, a shake on a wrong password.

### Orientation and continuity

Show where things come from and go: a card expanding into a detail page, a drawer sliding from the edge, a deleted item collapsing out of a list. This helps people keep their mental map.

### Status and progress

Loading spinners, progress bars, skeleton screens and pull-to-refresh indicators show that work is happening.

### Attention

A subtle pulse on a new notification or a gentle highlight on a changed value draws the eye — sparingly.

### Personality

Small moments of delight (a celebration after completing onboarding) express the brand. Keep them short and rare so they stay special.

## Duration

Most UI animations should be fast. Guidelines from Material Design and others suggest:

- Below about 100ms, motion is barely perceived. Above about 500ms, UI animation starts to feel slow.
- Larger distances and larger elements can take slightly longer.
- Mobile animations are often a little shorter than tablet or desktop ones because distances are smaller.

| Animation | Typical duration |
| --- | --- |
| Small changes: button states, toggles, fades, icon changes | 100–200ms |
| Medium: dropdowns, tooltips, cards expanding | 200–300ms |
| Large: full-screen transitions, sheets, page changes | 300–500ms |
| Exiting elements | Slightly faster than entering |

## Easing

In the real world, objects don't start and stop instantly — they accelerate and decelerate. **Easing** curves recreate this. Linear motion (constant speed) feels mechanical and is rarely right for UI movement.

| Easing | Behaviour | Use for |
| --- | --- | --- |
| Ease-out (decelerate) | Starts fast, slows down at the end | Elements entering the screen |
| Ease-in (accelerate) | Starts slow, speeds up | Elements leaving the screen |
| Ease-in-out (standard) | Slow start and end, fast middle | Elements moving within the screen |
| Linear | Constant speed | Progress bars, rotating spinners, colour/opacity fades |
| Spring | Overshoots slightly and settles, physics-based | Playful, natural-feeling interactions, gestures |

```css
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 240ms;
}
.sheet { transition: transform var(--duration-base) var(--ease-out); }
.button { transition: background-color var(--duration-fast) var(--ease-standard); }
```

## Choreography

- When several elements animate, **stagger** them slightly (e.g. 20–50ms apart) so the eye follows a clear order.
- Animate the most important element first.
- Avoid animating many unrelated things at once — it creates chaos.
- Keep motion consistent: the same type of element should always move the same way.
- Animate `transform` and `opacity` in code — they're smooth and cheap for the browser. Animating width, height or top causes jank.

## Loading states

| Pattern | When to use |
| --- | --- |
| Nothing | Under about 100ms — feels instant |
| Button spinner | Short actions like saving or submitting |
| Skeleton screen | Loading page content; shows the layout shape before data arrives |
| Progress bar (determinate) | Longer tasks where progress can be measured, like uploads |
| Spinner (indeterminate) | Unknown duration, a few seconds at most |
| Optimistic UI | Show the result immediately and sync in the background (likes, messages) |

## Accessibility and reduced motion

Large or fast motion — parallax, zooming, spinning — can trigger dizziness, nausea or headaches for people with vestibular disorders. Operating systems offer a **Reduce Motion** setting, which websites can read with `prefers-reduced-motion`.

- With reduced motion on, replace movement with simple fades or instant changes — don't remove feedback entirely.
- Never make people wait for an animation to finish before they can act.
- Avoid content that flashes more than three times per second (a WCAG requirement, as it can trigger seizures).
- Let users pause auto-playing carousels and videos.

```css
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
```

> Common mistake: Long, decorative page-load animations that delay content. They feel impressive the first time and annoying every time after.

## Tools for motion design

- **Figma** — Smart Animate and interactive components for prototype transitions.
- **Jitter** — motion design for UI and social content, exports to video, GIF and Lottie.
- **Rive** — interactive, state-driven animations that run in apps and websites.
- **Lottie** — a format for playing After Effects–style animations in apps and on the web.
- **Code** — CSS transitions, the Web Animations API, and libraries like Framer Motion or GSAP.

## Key takeaways

- Good motion is purposeful, quick and subtle: feedback, orientation, status, attention, personality.
- Microinteractions have a trigger, rules, feedback, and loops & modes.
- Most UI animations last 100–300ms; large transitions up to about 500ms.
- Ease-out for entering, ease-in for exiting, standard easing for moving; avoid linear for movement.
- Respect prefers-reduced-motion, never block users with animations, and avoid flashing content.

## Exercise: Design a microinteraction

1. Choose a small moment, e.g. adding an item to a cart.
2. Write down its trigger, rules, feedback, and loops & modes.
3. Prototype it in Figma with Smart Animate (or in Jitter/Rive) using 150–300ms and ease-out.
4. Design the reduced-motion version (e.g. a simple fade).
5. Show it to someone and ask what they think happened.

## Quiz

1. A typical duration for small UI transitions is…
   - 10–30ms
   - **100–200ms** ✓
   - 1–2 seconds
   - 5 seconds
   - Why: Fast enough to feel responsive, slow enough to be seen.

2. Which easing suits an element entering the screen?
   - **Ease-out** ✓
   - Ease-in
   - Linear
   - No easing
   - Why: Ease-out starts fast and settles gently.

3. What are the four parts of a microinteraction?
   - Plan, design, build, test
   - **Trigger, rules, feedback, loops & modes** ✓
   - Start, middle, end, repeat
   - Color, type, space, motion
   - Why: Dan Saffer's model: trigger, rules, feedback, loops & modes.

4. Which properties are cheapest to animate in the browser?
   - width and height
   - top and left
   - **transform and opacity** ✓
   - margin and padding
   - Why: transform and opacity can be animated without recalculating layout.

5. What should happen when a user has 'reduce motion' turned on?
   - Nothing
   - **Replace movement with simple fades or instant changes** ✓
   - Show more animation
   - Block the site
   - Why: Respect prefers-reduced-motion while keeping feedback.
