Easily add smooth animations to your React Apps

⚛️ Learn @framer Motion in 10 Tweets ⚛️
1️⃣ @framer motion is a production ready @reactjs animation library. Created by @mattgperry

Simple syntax with smart defaults that will make your animations look good.

To get started import motion and add 'motion.' before any HTML or SVG element.

This gives you new props
2️⃣ The animate prop lets you pass in an object with the details of the animation.

You can change the position, scale, opacity, and many others

Once set Framer will take care of animating the element. You can customize the animation with the transition prop covered later.
3️⃣ Use the initial prop to tell framer what state you want to element to be in before the animation starts.

You can have the elements start out invisible then gradually appear with the animation
4️⃣ Use the transition prop you customize how the element will animate from initial to animate.

You can change the duration, animation type, delay, how many times it runs, and more.
5️⃣ Keyframes are arrays you can pass in to the animate prop with different values.

Framer will animate through each once starting with the first value in the array
6️⃣ Animation are even better when users can interact with them motions components get helper props that animate on action like hovers and clicks
7️⃣ Another gesture is drag. Adding this props make the component draggable.

You can set it to "x" or "y" to keep the dragging to only the x or y axis.

You can add dragConstraints to set boundaries of where the element can be dragged
8️⃣ Variants let you extract a lot of animation code out of the component.

Create a variants object and place in the key/value pairs a name and and object with the properties you want to animate.

Pass the object to the variants props and access the animation values with strings
9️⃣ Variants also let you add animations to children components.

staggerChildren will animate each child element with a time delay that you can set before the next animation runs.
🔟 AnimatePresence lets you animate components when they're removed from the React tree.

Wrap motion components with AnimatePresence and add the exit prop to the component you want to be animated when it's removed.
You'll learn how to add all these features in a real app with my new @eggheadio course coming soon!

Sign up at motion.williamjohnson.dev to get a free 5 min video lesson!
Thank you for the RT Matt!
Heres a link to the beginning of the thread

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Fresh Prince of JavaScript 🛡️

Fresh Prince of JavaScript 🛡️ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @willjohnsonio

Jan 4, 2021
🔥 Learn Ruby On Rails in 10 tweets! 🔥 Image
1️⃣ Ruby on Rails is a full-stack web app building framework made with the Ruby programming language.

Ruby has clean, simple syntax without tons of parenthesis, brackets, or semi-colons

@github @Shopify @Calendly @ThePracticalDev @eggheadio & @ConvertKit were built using Rails Image
2️⃣. Rails use the MVC(Model. View. Controller) programming pattern to organize and separate your code.

This makes it easier to know where things are and how they are connected which gives you more time to focus on building features users need Image
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(