react-gsap Docs
Introduction
Components
TweenUse "to" propUse "from" propUse "from" and "to" propUse stagger propPropsType StaggerEnum PlayStateTimelineScrollTriggerRevealSplitCharsSplitWordsControls
Plugins
Instructions

Tween

The Tween component uses the gsap.to(), gsap.from() and gsap.fromTo() functions internally.

The children need to be "refable" components. So they can be HTML elements or forwardRef components like styled-components components.

import { Controls, PlayState, Tween } from 'react-gsap';

Use "to" prop

Use "from" prop

Use "from" and "to" prop

Internally the gsap.fromTo() function will be called.

Use stagger prop

If you have multiple children you can make use of the stagger prop.

More info: https://greensock.com/docs/v3/Staggers

Advanced stagger

Props

The question mark means it's an optional prop.

For a documentation of all possible props or from and to values check out the documentations: vars, gsap.to(), gsap.from() and gsap.fromTo()

NameTypeDescription
children?React.ReactNodeNeed to be "refable" components. So they can be HTML elements or forwardRef components like styled-components components
wrapper?anyThis component gets wrapped around the Tween component
target?number | stringThe target index or key of the Timeline targets. Used if Tween is childless and child of a Timeline
position?string | numberIf this Tween is a child from a Timeline it's added at this position
from?anyThe vars object for the gsap.from() or gsap.fromTo() function
to?anyThe vars object for the gsap.to() or gsap.fromTo() function
stagger?number | Stagger | (index: number, target: any, list: any) => numberIf multiple children are added, you can stagger the start times for each
duration?numberThe duration of the animation (in seconds) (Can be changed on-the-fly)
progress?number0 - 1 (Can be changed on-the-fly)
totalProgress?number0 - 1 (Can be changed on-the-fly)
playState?PlayStateUse it to control the playing state (Can be changed on-the-fly)
disabled?booleanon-the-fly changes and are no more possible
onlyInvalidateTo?boolean
[prop: string]anyAll other props are added to the vars object for the Tween functions

Type Stagger

More info: https://greensock.com/docs/v3/Staggers

NameType
amount?number
each?number
from?'start' | 'center' | 'edges' | 'random' | 'end' | number | [number, number]
grid?[number, number] | 'auto'
axis?'x' | 'y'
ease?string | (value: number) => number
repeat?number
yoyo?boolean
[prop: string]any

Enum PlayState

FieldAs string
play"play"
restart"restart"
reverse"reverse"
restartReverse"restartReverse"
stop"stop"
stopEnd"stopEnd"
pause"pause"
resume"resume"