Sub topic 10
Specifying Interactions and Motion
This chapter assumes you can read basic CSS, know the component states from the previous chapter (hover, focus, active, disabled), and use named design tokens. A static frame shows what a screen looks like. It does not show what happens between two states. Interaction and motion specs fill that gap.
What an interaction spec covers
An interaction spec answers four questions for each behavior:
- Trigger: what starts it (hover, click, focus, scroll, a timer, a server response).
- Change: which properties move from which value to which value.
- Timing: how long it takes, how it eases, and whether it waits first.
- Reversal: what happens when the trigger ends, or is interrupted halfway.
Most handoff gaps come from the fourth question. If a menu opens in 200 ms and the user closes it at 100 ms, the developer has to guess unless you say otherwise.
Name durations and easings as tokens
Motion values repeat across a product, so treat them like color and spacing. Give them names once and refer to those names in your notes.
:root {
--duration-fast: 120ms;
--duration-base: 200ms;
--duration-slow: 320ms;
--ease-standard: cubic-bezier(0.2, 0, 0, 1);
--ease-exit: cubic-bezier(0.4, 0, 1, 1);
}A note that says "uses duration-base, ease-standard" is shorter and less ambiguous than "about a fifth of a second, smooth". It also keeps every component in step when you change one value.
A worked example: a dropdown menu
Suppose a design includes a dropdown. A useful annotation lists the behavior as a table.
| Trigger | Change | Timing | Reversal |
|---|---|---|---|
| Click on toggle | Panel fades in and moves down 8px | duration-base, ease-standard | Click again, Escape, or click outside reverses it |
| Escape key | Panel fades out, focus returns to toggle | duration-fast, ease-exit | None |
| Item hover | Background changes to the hover token | duration-fast | Returns on pointer leave |
The developer can turn that table directly into code.
.menu-panel {
opacity: 0;
transform: translateY(-8px);
visibility: hidden;
transition:
opacity var(--duration-base) var(--ease-standard),
transform var(--duration-base) var(--ease-standard),
visibility 0s linear var(--duration-base);
}
.menu-panel[data-open="true"] {
opacity: 1;
transform: translateY(0);
visibility: visible;
transition-delay: 0s;
}The visibility rule is a detail worth noting in a spec: a hidden panel must also leave the keyboard tab order, so it cannot only be transparent.
Choose the right kind of motion
Not every animation is a transition between two states. State which kind you mean.
- Transition: a change between two states, such as a hover color. Simple to build in CSS.
- Animation: a multi-step sequence, such as a skeleton shimmer or a spinner. Give the keyframes and whether it loops.
- Scroll or gesture driven: motion tied to scroll position or dragging. These cost the most to build, so flag them early.
Prefer animating opacity and transform. Animating width, height, or top forces the browser to recompute layout and often looks choppy on slower devices. If your design needs a height change, say so, and let the developer pick the technique.
Reduced motion
Some users set their operating system to reduce motion because movement can cause discomfort or nausea. Every handoff with motion should say what replaces it. A common rule is to keep fades and remove movement.
@media (prefers-reduced-motion: reduce) {
.menu-panel {
transform: none;
transition-duration: var(--duration-fast);
}
}Common errors
- Giving only a duration and no easing, so the developer picks a default that feels different from the prototype.
- Describing the "after" state but not what happens on a second click or a canceled action.
- Specifying motion on hover only, with no equivalent for keyboard focus or touch.
- Looping animations with no stop condition, such as a spinner that never times out.
- Leaving out the reduced-motion behavior.
Exercise
A designer hands off a modal dialog with the note "fades in nicely". List the four things the spec is missing, using the trigger, change, timing, and reversal questions, and name one thing to add for users who prefer reduced motion.
Show answer
Trigger: what opens the modal (button click) and what closes it (close button, Escape, backdrop click). Change: which properties animate, for example opacity from 0 to 1 and a small upward transform on the dialog, plus the backdrop fade. Timing: a duration and easing token such as duration-base and ease-standard, with the exit being faster. Reversal: what happens if the user closes it while it is still opening. For reduced motion, remove the transform and keep only a short opacity fade, or show the dialog instantly. Also worth stating: focus moves into the dialog on open and returns to the trigger on close.