Fetching documentation…
CSS transitions animate style changes when a property value changes — typically triggered by :hover.
.btn {
transition: all 0.3s ease-in-out;
}This makes every property change on .btn animate smoothly over 0.3 seconds.
.card {
transition-duration: 0.2s;
transition-timing-function: ease;
}/* all properties, 0.3s, ease-in-out */
transition: all 0.3s ease-in-out;
/* specific property */
transition: background-color 0.2s ease;
/* multiple transitions */
transition: color 0.3s ease, background-color 0.5s ease-in-out;| Value | Behavior |
|---|---|
linear |
Constant speed |
ease |
Alias for ease-in-out |
ease-in |
Slow start |
ease-out |
Slow end |
ease-in-out |
Slow start and end (default) |
cubic-bezier() and steps() are not supported yet — they fall back to the default easing.
These properties interpolate smoothly (numbers lerp, colors blend):
background-color, color — RGBA interpolationmargin, padding — per-side numeric interpolationborder-width, border-radius — numeric interpolationborder-color — RGBA interpolationfont-size, gap — numeric interpolationwidth, height — interpolated when both values are explicitopacity — numeric interpolationleft, right, top, bottom — numeric interpolationThese properties snap instantly (no interpolation):
display, position, flex-direction, font-weightoverflow, text-align, box-sizing, border-stylecursor, margin-auto.btn {
background-color: #6366f1;
color: #ffffff;
transition: all 0.3s ease;
}
.btn:hover {
background-color: #4f46e5;
transform: translateY(-2px);
}.card {
border: 1px solid #334155;
transition: border-color 0.3s ease, transform 0.3s ease;
}
.card:hover {
border-color: #6366f1;
transform: translateY(-4px);
}.parent:hover .child transitions work — when the parent is hovered, the child's style changes animate:
.card:hover .card-title {
color: #6366f1;
}
.card-title {
transition: color 0.3s ease;
}Transitions run per-node — parent and child can transition independently.
Setting transition-duration: 0 (or omitting the transition) disables animation — style changes snap instantly. This is the default behavior and is fully backward-compatible.