API Overview
All the Framer Motion properties, events, and utilities.
Here’s an overview of the Framer Motion API properties, user events, extra components, and utility functions,… with links to where they’re explained or used in the book. The Framer Motion 3D integration with React Three Fiber is not yet included.
For a demo of the visual and layout properties that you can actually animate, check Animatable Properties.
Framer API
Need to know which properties a <Page>
or <Scroll>
has? The old legacy docs were online at https://www.framer.com/legacy/docs but were removed with the launch of Framer Sites. I found copies on the Wayback Machine for <Frame>
and <Page>
, but not for <Scroll>
and <Stack>
. Hopefully, we’ll see new docs appear with the current APIs of these Framer Library components.
Animation properties
Every Frame and Motion element has this set of properties that make animations happen.
Other Framer components like <Scroll>
, <Page>
, and <Stack>
will also have these properties.
Transition options
Some transition
settings you can only use with tween curves, others only with a spring, but adding repetitions or a delay is possible with both.
Orchestration options
You can orchestrate child animations by adding these settings to their parent’s transition
. Important: they’ll only work with variants.
Motion API | Tween | Spring | |
---|---|---|---|
delayChildren
|
✅ | ✅ | Animation orchestration |
staggerChildren
|
✅ | ✅ | Animation orchestration |
staggerDirection
|
✅ | ✅ | Animation orchestration |
when
|
✅ | ✅ | Animation orchestration |
custom
|
✅ | ✅ | Variants > The custom property |
inherit
|
✅ | ✅ |
Drag properties
Change the behavior of a draggable element with these properties.
Drag transition options
Releasing a draggable element starts an inertia animation, which you can tweak with these dragTransition
options.
Events
An overview of the user events a frame or motion element will react to. Plus also: the ‘while’ gesture animations.
You can also use common browser events. React will turn them into synthetic events (which still contain a reference to the original event).
Frames and motion elements have a few more events that are triggered by animations:
Motion API |
---|
onAnimationStart()
|
onUpdate()
|
onAnimationComplete()
|
onLayoutAnimationStart()
|
onLayoutAnimationComplete()
|
You can set configuration options for the whileInView
animation helper on the viewport
property.
Motion API |
---|
viewport
|
↳
once
|
↳
root
|
↳
margin
|
↳
amount
|
Special components
Sometimes you need to wrap everything in a parent component that enables unmount animations: <AnimatePresence>
, or you might want to synchronise a set of layout animations in a <LayoutGroup>
.
Motion values
Hooks and other functions to create, transform, or animate Motion values.
There are special Motion values that you can use to change the path of an SVG motion.circle
, motion.ellipse
, motion.line
,motion.path
, motion.polygon
, motion.polyline
, or motion.rect
.
Motion API | |
---|---|
pathLength
|
Line Drawing > Extra convenience properties |
pathSpacing
|
Line Drawing > Extra convenience properties |
pathOffset
|
Line Drawing > Extra convenience properties |
The Motion value API
Every Motion value has these methods. Use them to get its current value, change that value, or subscribe to value changes.
Utilities
These are the remaining Framer Library and Framer Motion utilities. The transform()
function is a version of the useTransform()
hook (see above) that works with common numeric values.
AnimationControls object
The useAnimationControls()
hook creates an AnimationControls object. These methods let you start and stop animations or instantly change the animated properties to a different value.
Note: The useAnimationControls()
hook is being phased out in favor of the recently added (Framer Motion 10.5) useAnimate()
hook.
Motion API | |
---|---|
start()
|
The useAnimationControls() Hook, Keyframes |
set()
|
|
stop()
|
The useAnimationControls() Hook |