Fireship · @fireship
Springy Animated Modals // Framer Motion & React Tutorial for Beginners
Uploaded September 14, 2021 · Length 11:03
Summary
Learn how to build a modal window with animations using Framer Motion and React from scratch in this beginner-friendly tutorial.
- framer motion tutorial
- react animations
- modal window example
- beginner react tutorial
- ui component development
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
animation is one of the most satisfying
- 0:01
things for a developer because it can
- 0:03
turn a boring cookie cutter feature into
- 0:05
something really special in today's
- 0:07
video we'll build a modal window and
- 0:08
react from scratch but on top of that
- 0:11
we'll also bring in a library called
- 0:12
framer motion to implement a bunch of
- 0:14
crazy animations for the modal in this
- 0:16
beginner-friendly tutorial you'll learn
- 0:18
how to style a modal with css then how
- 0:20
to manage its open and closed state with
- 0:22
javascript and most importantly how to
- 0:24
implement declarative animations with
- 0:26
framer motion and react and i'll even
- 0:28
show you how to drag and move a modal
- 0:30
around the screen and explain the
- 0:31
physics behind motion like this and
- 0:33
we'll look at a bunch of other cool
- 0:34
tricks and best practices along the way
- 0:36
if you're new here like and subscribe
- 0:38
and if you like this tutorial upgrade to
- 0:40
a pro membership on fireship io to get
- 0:42
access to the sequel where we build a
- 0:44
notification system with framer before
- 0:46
we jump into the code let's take a
- 0:47
closer look at what we're building today
- 0:49
and by the way there's also a live demo
- 0:50
where you can play around with this
- 0:52
project before you build it we have a
- 0:53
button that when clicked will add a
- 0:55
backdrop to the entire screen and then
- 0:57
animate a window on top of it then to
- 0:59
close it we can either click the close
- 1:01
button or click outside of it on the
- 1:03
backdrop which will automatically
- 1:04
trigger the outro animation modals are a
- 1:07
very useful ui feature when you need to
- 1:09
focus the user's attention and or you
- 1:11
don't want to navigate them to an
- 1:12
entirely different route you can also do
- 1:14
complex things inside of them for
- 1:16
example the entire login feature for
- 1:18
fireship io is handled inside of a modal
- 1:20
what you don't want to do is pop one of
- 1:22
these things up after a few seconds
- 1:23
asking someone to subscribe to your
- 1:25
newsletter or even worse asking them to
- 1:27
accept cookies let's go ahead and jump
- 1:29
into the code to get started we'll first
- 1:31
need to generate a react project and for
- 1:33
that i'm using create react app once
- 1:35
created i'll go ahead and open it up in
- 1:37
vs code and install our only dependency
- 1:39
which is framer motion framer by the way
- 1:42
is maintained by the team behind the
- 1:43
framer design tool and is a very well
- 1:45
maintained and polished library for
- 1:47
implementing animations it's not the
- 1:49
only way to animate and react but in my
- 1:50
opinion it's the most intuitive approach
- 1:52
for a feature like this now to run the
- 1:54
app run npm start from the command line
- 1:56
and that should bring up the default
- 1:58
react app on localhost 3000. next we'll


