Home / Snippets / Animation & Motion /

Fade in entrance

Elements fade up on page load — pure CSS, no JavaScript.

First
Second
Third
New
animationno-js

Quick implementation

.fade-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

@starting-style {
  .fade-in {
    opacity: 0;
    transform: translateY(1rem);
  }
}

/* Stagger children */
.fade-in:nth-child(2) { transition-delay: 0.1s; }
.fade-in:nth-child(3) { transition-delay: 0.2s; }
.fade-in:nth-child(4) { transition-delay: 0.3s; }

Prompt this to your LLM

Includes role, constraints, and motion-safety considerations.

You are a senior frontend engineer building page entrance animations.

Goal: Fade-in + slide-up entrance for elements when they first render, using @starting-style — no JavaScript.

Technical constraints:
- Use @starting-style to define the "before" state (opacity: 0, translateY(1rem)).
- The element's normal state is the "after" state (opacity: 1, translateY(0)).
- Use transition (not @keyframes) for the animation.
- ease-out timing, 0.4–0.6s duration.
- Stagger siblings with transition-delay using :nth-child().
- Wrap motion in @media (prefers-reduced-motion: no-preference) — disable for users who prefer reduced motion.

Variations:
A) Fade up (translateY).
B) Fade in from left (translateX).
C) Scale in (scale(0.95) to scale(1)).

Return CSS only. No JavaScript.

Why this matters

Entry animations used to require JavaScript — IntersectionObserver, animation libraries, or framework-specific solutions. @starting-style lets CSS define what an element looks like at the moment it first renders. The browser automatically transitions from that state to the element's normal style. Zero JavaScript, zero hydration delay.

The logic

@starting-style declares the initial values for properties that have transitions. When the element enters the DOM (or becomes visible), the browser computes the starting style, then immediately transitions to the computed style. The element never actually "stays" at opacity 0 — it transitions in one frame.

Accessibility & performance

Always wrap entrance animations in @media (prefers-reduced-motion: no-preference). Users with vestibular disorders may find slide animations disorienting. opacity and transform are compositor-only properties — they don't trigger layout or paint, so even staggering dozens of elements is cheap. Supported in Chrome 117+, Safari 17.5+, Firefox 129+.