Skip to content

Animations

Transitions provide feedback, maintain context, and guide attention. Use them purposefully—not every state change needs animation.

Motion speed affects perceived responsiveness. Faster isn’t always better.

TokenDurationUse for
--tng-transition-duration-2xf100msIcon transforms, micro-interactions
--tng-transition-duration-xf200msHover states, color changes, small toggles
--tng-transition-duration-f300msDropdowns, accordions, medium ui changes
--tng-transition-duration-m400msModals, large panels, complex layouts
--tng-transition-duration-s600msPage transitions, dramatic reveals

Rule of thumb: Smaller elements and property changes = faster durations. Large or distant movements need time for the eye to track.

Easing makes motion feel natural rather than robotic. Choose the right curve for the job.

For polished motion with custom curves tuned to the brand:

Use for: Entrances, expansions, reveals—UI appearing or growing.

.dropdown {
transition: opacity var(--tng-transition-duration-f)
var(--tng-transition-ease-out);
}

Starts fast (immediate feedback) then decelerates smoothly. This is your default for most UI transitions.

Use for: Reversible movements, elements sliding between positions.

.indicator {
transition: translate var(--tng-transition-duration-xf)
var(--tng-transition-ease-in-out);
}

Symmetric acceleration/deceleration feels balanced when direction reverses.

Standard CSS timing functions for common scenarios:

Use for: Hover effects, focus states, simple interactive feedback.

.card {
transition: transform var(--tng-transition-duration-xf) ease;
}
.card:hover {
transform: scale(1.02);
}

Similar to ease-out with a slightly different curve. Good default for basic interactions.

Use for: Color/opacity changes, rotations, loading spinners.

.button {
transition: background-color var(--tng-transition-duration-xf) linear;
}

Constant speed prevents visual distraction. Avoid for movement—it feels mechanical.

EasingUse case
--tng-transition-ease-outMost UI transitions (default)
--tng-transition-ease-in-outReversible/sliding movements
easeHover/focus effects
linearColors, opacity, spins/rotates
  • Instant feedback actions: Clicks, selections, immediate toggles
  • User-triggered scrolling: Let the browser handle it
  • Large data updates: Don’t animate hundreds of items
  • Already in motion: Don’t interrupt existing animations

Always respect prefers-reduced-motion (WCAG 2.3.3). Users who enable “reduce motion” in their OS settings may experience motion sickness, vestibular disorders, or simply prefer less animation.

.details::details-content {
transition: block-size var(--tng-transition-duration-f)
var(--tng-transition-ease-out);
}
@media (prefers-reduced-motion: reduce) {
.details::details-content {
transition-duration: 0.01ms;
}
}
  • Never auto-play animations that last longer than 5 seconds without giving the user a way to pause or stop them (WCAG 2.2.2).
  • Avoid flashing content that flashes more than 3 times per second (WCAG 2.3.1).