Transitioning Multiple Properties
You'll learn how to smoothly animate several CSS properties at once or give each property its own unique timing.
The Core Idea
So far you've applied transition to a single property, but real-world animations often involve multiple changes happening simultaneously—or at different speeds. CSS lets you orchestrate these by listing multiple properties in the transition shorthand, each with its own duration and timing function.
Think of it like a symphony: some instruments (properties) fade in slowly while others hit their notes quickly. You're the conductor deciding which changes happen when.
Multiple Properties, One Transition
You can animate several properties together by separating them with commas:
.card {
transition: opacity 0.3s ease-in, transform 0.5s ease-out;
}
When state changes trigger both opacity and transform updates, opacity completes in 300ms while transform takes 500ms—each with its own easing curve.
The all Keyword
If you want every animatable property to transition, use all:
.button {
transition: all 0.4s ease;
}
This applies the same duration and timing to background-color, color, transform, opacity, and any other property that changes. It's convenient but less performant—only transition what you actually need.
In React Components
Apply this directly via className or inline style:
<div
style={{
transition: 'opacity 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
}}
className={isActive ? 'active' : ''}
/>
When isActive toggles, both properties animate at their specified speeds.
Key Takeaway: Use comma-separated transition values to choreograph multiple CSS properties with independent timings, creating richer, more nuanced animations than single-property transitions allow.