Skip to main content
GSAP Animation TutorialArticle 04

Understanding gsap.from(): Animate Elements Into Their Current State

Build entrances by describing where an element begins, then let GSAP animate it into the final layout already defined by your CSS.

Understanding gsap.from() Animation Tutorial - NavTechSolution

Entrance animation often begins with a simple idea: content starts somewhere else and arrives in its normal layout. gsap.from() expresses that idea directly. It is useful for page-load entrances, heading reveals, cards, images, buttons, and section introductions.

A simple entrance
gsap.from(".title", {
  y: 40,
  opacity: 0,
  duration: 1
})

The title temporarily begins 40 pixels lower and invisible. It then animates into its normal CSS position and visibility.

The mental model

Custom starting state → gsap.from() → current CSS state. The object describes the entrance, while your stylesheet describes the finished layout.

1. What is gsap.from()?

gsap.from() defines starting values. GSAP temporarily applies those values and animates toward the target’s current computed state.

Enter from the left
gsap.from(".box", {
  x: -200,
  duration: 1
})

2. gsap.to() versus gsap.from()

The difference is which side of the journey you describe:

gsap.to()

Current → destination

gsap.to(".box", { x: 200 })

Start where the box is now and finish at x 200.

gsap.from()

Custom start → current

gsap.from(".box", { x: -200 })

Begin at x -200 and finish where the box is currently styled.

If you need a refresher on destination tweens, read Understanding gsap.to().

3. Your first gsap.from() animation

Replayable entrance
<div class="from-demo-box"></div>

gsap.from(".from-demo-box", {
  x: -150,
  opacity: 0,
  duration: 1.2,
  ease: "power2.out"
})
FROM

The box is in its current CSS state.

Before replay, the demo kills an active tween and restores x, opacity, rotation, and scale. It then creates a fresh from() tween.

4. Fade-in animation

Fade from transparent
gsap.from(".fade-item", {
  opacity: 0,
  duration: 1
})

The normal state remains visible at opacity 1. GSAP begins at opacity 0 and interpolates back to that visible state.

Visible destination

Opacity is currently 1.

5. Slide in from the left

Negative x entrance
gsap.from(".slide-left", {
  x: -100,
  opacity: 0,
  duration: 1,
  ease: "power2.out"
})

x: -100 places the temporary start 100 pixels left of the final position. In responsive demos, reduce that distance or clip the isolated stage so it cannot widen the page.

6. Slide in from the right

Positive x entrance
gsap.from(".slide-right", {
  x: 100,
  opacity: 0,
  duration: 1,
  ease: "power2.out"
})

A positive x value begins to the right and returns to the normal x position. The final CSS remains unchanged.

7. Reveal from below

Positive y entrance
gsap.from(".reveal-up", {
  y: 50,
  opacity: 0,
  duration: 0.9,
  ease: "power2.out"
})

Positive y begins below the normal position. This restrained pattern often suits headings, paragraphs, cards, and CTA blocks.

8. Reveal from above

Negative y entrance
gsap.from(".reveal-down", {
  y: -50,
  opacity: 0,
  duration: 0.9,
  ease: "power2.out"
})

Negative y begins above; positive y begins below. Both end at the same current position.

9. Scale-in animation

Begin smaller
gsap.from(".scale-card", {
  scale: 0.8,
  opacity: 0,
  duration: 0.8,
  ease: "back.out(1.4)"
})

scale: 0.8 begins at 80% of the normal size. The back ease adds a small settling character; easing receives a dedicated lesson later.

10. Rotation entrance

Subtle rotated start
gsap.from(".rotate-item", {
  rotation: -15,
  opacity: 0,
  duration: 0.8,
  ease: "power2.out"
})

The element begins rotated counter-clockwise and settles at its normal rotation. Small angles can add direction without making routine interface content feel unstable.

11. Combine multiple starting properties

One combined entrance
gsap.from(".feature-card", {
  y: 50,
  opacity: 0,
  scale: 0.9,
  rotation: 2,
  duration: 1,
  ease: "power2.out"
})

Every transform and opacity value above describes the start. The destination remains the card’s current CSS state: y 0, visible opacity, normal scale, and its existing rotation.

12. Hero section entrance example

NavTechSolution

Build Better Digital Experiences

Modern web development with thoughtful motion.

Explore ServicesHero content is in its final state.
Hero title entrance
gsap.from(".hero-demo-title", {
  y: 50,
  opacity: 0,
  duration: 1,
  ease: "power2.out"
})

The demo animates its isolated hero elements together. Later lessons will show how stagger and timelines create deliberate sequences.

13. Why gsap.from() fits entrances

The HTML and CSS can describe the final, readable interface. JavaScript only describes how it enters:

Final state plus entrance
.title {
  opacity: 1;
}

gsap.from(".title", {
  opacity: 0,
  y: 30
})

If JavaScript does not run, the title remains visible in its normal layout. That is a useful progressive-enhancement foundation.

14. A brief note on immediateRender

From-based tweens can apply their starting values immediately when created. You may notice this more in timelines or when several from/fromTo tweens affect the same target.

Advanced option
gsap.from(".box", {
  opacity: 0,
  immediateRender: false
})

Most beginner entrances do not need to change this option. Treat it as a troubleshooting clue when multiple tweens compete over the same starting values.

15. Use gsap.from() with multiple elements

Shared card entrance
<div class="from-card">HTML</div>
<div class="from-card">CSS</div>
<div class="from-card">JavaScript</div>

gsap.from(".from-card", {
  y: 30,
  opacity: 0,
  duration: 0.8
})
HTML
CSS
JavaScript

All matches share the same starting values and can enter together. A later lesson shows how stagger makes them enter one after another. Review GSAP targeting elements for selector details.

16. Interactive entrance playground

Each button restores the card’s final state, kills any active tween, and creates a fresh gsap.from() entrance.

Current CSS stateEntrance Card

Choose a temporary starting state.

17. Practical navigation and UI reveal

The example below is isolated from the real website navigation.

Demo navigation is visible.
Navigation entrance
gsap.from(".demo-nav-item", {
  y: -15,
  opacity: 0,
  duration: 0.5
})

18. Practical card reveal

NavTechSolution

Web Performance

Reduce friction with focused technical improvements.

Service card is in its final layout.
Service card entrance
gsap.from(".service-demo-card", {
  y: 40,
  opacity: 0,
  scale: 0.95,
  duration: 0.8,
  ease: "power2.out"
})

19. Page-load animation

Wait for static PHP markup
document.addEventListener("DOMContentLoaded", () => {
  gsap.from(".page-heading", {
    y: 40,
    opacity: 0,
    duration: 1
  })
})

On a static PHP page, DOMContentLoaded safely waits until the rendered HTML is available. Do not permanently set essential content to opacity 0 in CSS when JavaScript is the only mechanism that reveals it.

20. CSS defines the final state

Final CSS and temporary start
.demo-card {
  opacity: 1;
  transform: none;
}

gsap.from(".demo-card", {
  y: 40,
  opacity: 0,
  scale: 0.95
})

21. Common gsap.from() mistakes

From is confused with to

x: -100 means begin there and return to normal—not finish there.

Essential content is hidden in CSS

Keep important content readable when JavaScript fails or is disabled.

Replay logic reuses a finished state

Kill the old tween, restore final values, and create a fresh from tween.

The start is extremely far away

Large offsets can create mobile overflow and distracting travel.

The selector is wrong

Confirm the class, ID, or DOM reference exists in the isolated component.

GSAP is not loaded

Load the CDN before the page-specific script.

JavaScript runs too early

Wait for the DOM when the target markup is not yet available.

CSS transforms conflict

Review transforms already defined on the element and its interactive states.

Reduced motion is ignored

Skip decorative entrances and show the final state directly when requested.

From is expected to set the destination

The destination is normally the current state. Use fromTo() when both ends must be explicit.

22. gsap.from() versus CSS animation

CSS animations are excellent for simple, declarative effects that belong naturally in a stylesheet. GSAP becomes useful when you need JavaScript control, interaction, sequencing, timelines, ScrollTrigger, or values calculated at runtime. Neither is universally better; choose the tool that keeps the behavior understandable.

23. Performance tips

When appropriate, prefer entrance examples based on x, y, scale, rotation, and opacity. Transform and opacity properties are commonly suitable for interface motion, but target count, element size, effects, and device capability still matter. Test the real page.

24. Accessibility and reduced motion

Motion preference
const reduceMotion = window.matchMedia(
  "(prefers-reduced-motion: reduce)"
).matches

if (reduceMotion) {
  gsap.set(".card", { x: 0, y: 0, opacity: 1 })
} else {
  gsap.from(".card", { y: 40, opacity: 0 })
}

When reduced motion is requested, skip decorative travel and preserve every label, link, and control. All demos in this article show their final state immediately.

25. Mini challenge

Profile markup
<div class="challenge-profile">
  <div class="challenge-avatar"></div>
  <h3>Frontend Developer</h3>
  <p>Building fast and interactive web experiences.</p>
</div>

Make the profile begin 50 pixels lower, at opacity 0 and scale 0.9. Animate for one second with power2.out, finishing in its normal CSS state.

Show one possible solution
Challenge solution
gsap.from(".challenge-profile", {
  y: 50,
  opacity: 0,
  scale: 0.9,
  duration: 1,
  ease: "power2.out"
})

26. gsap.from() quick reference

PropertyStarting effectExample
xStart left or rightx: -100
yStart above or belowy: 50
opacityStart transparentopacity: 0
scaleStart smaller or largerscale: 0.8
rotationStart rotatedrotation: -15
durationAnimation lengthduration: 1
delayWait before startingdelay: 0.3
easeMotion feelpower2.out

27. Remember the gsap.from() mental model

Remember
Startx: -150
opacity: 0
scale: 0.8
gsap.from(".box", {
  x: -150,
  opacity: 0,
  scale: 0.8
})
Current CSSx: 0
opacity: 1
scale: 1

The object passed to gsap.from() mainly describes where the animation begins. The current CSS tells it where to finish.

Frequently asked questions

What does gsap.from() do?

gsap.from() applies temporary starting values and animates the target from those values into its current CSS or computed state.

What is the difference between gsap.to() and gsap.from()?

gsap.to() defines destination values. gsap.from() defines starting values and uses the target’s current state as the destination.

Is gsap.from() good for entrance animations?

Yes. It is well suited to entrances because the normal HTML and CSS can remain in their final usable state while JavaScript describes how they enter.

Can gsap.from() animate opacity?

Yes. Starting from opacity 0 creates a fade into the element’s current opacity, which is usually 1.

Can gsap.from() animate multiple elements?

Yes. A selector, NodeList, or array can supply multiple targets that share the same starting values.

Why does my gsap.from() animation only play once?

The element is already at its destination after the first run. For manual replay, kill the old tween, restore the final state, and create a new from tween.

Can I use gsap.from() on a PHP website?

Yes. PHP renders the HTML and GSAP animates those elements in the browser after the document is available.

Should I hide elements with CSS before using gsap.from()?

Avoid permanently hiding essential content only to reveal it with JavaScript. Let CSS describe the readable final state and let gsap.from() apply temporary starting values when it runs.

Your entrance-animation foundation

You can now build entrances while keeping the final page readable in normal CSS. Revisit the GSAP introduction, targeting elements, or the gsap.to() tutorial whenever you need the earlier mental models.