Animations

Setting Up custom cursors in Framer (Animation Lesson 16)

Setting Up custom cursors in Framer (Animation Lesson 16)

Setting Up custom cursors in Framer (Animation Lesson 16)

Joseph

·

12:17

·

13K views

·

About this lesson

If “variety is the spice of life” then why do we use this same arrow cursor all the time? Lucky for us, Custom cursors in Framer let us design unique cursor styles that match your brand and respond to interactions.

In this lesson, we’ll look at a few different approaches for adding custom cursors to our sites.

https://www.youtube.com/watch?v=FakL-liq890&t=0s Intro

https://www.youtube.com/watch?v=FakL-liq890&t=23s Cursor options overview

https://www.youtube.com/watch?v=FakL-liq890&t=108s Build a simple cursor component

https://www.youtube.com/watch?v=FakL-liq890&t=179s Replace vs follow and transition basics

https://www.youtube.com/watch?v=FakL-liq890&t=399s Set variant

https://www.youtube.com/watch?v=FakL-liq890&t=620s Cleanup

https://www.youtube.com/watch?v=FakL-liq890&t=713s Wrap up

Sign up: https://framer.link/yt

Follow: https://framer.link/yt-x

Learn: https://framer.link/yt-academy

0:00If variety is the spice of life, then0:03why do we keep using the same arrow0:05cursor all the time? Well, lucky for us,0:07custom cursors in Framer let us design0:10unique cursor styles that match our0:12brand and respond to interactions. In0:15this lesson, we'll look at a few0:16different approaches for adding custom0:18cursors to our sites.0:22To set a custom cursor, first we got to0:25decide where on the page that cursor0:27should appear in the first place. We'll0:29start with something simple. We'll0:31replace the cursor with something a0:32little more interesting no matter where0:34the cursor is on the entire page, which0:37we accomplish by first selecting the0:39desktop breakpoint and then coming down0:41here to the properties panel and0:43clicking the cursor section. We get a0:46few different options here. We have web0:47cursor which lets us choose from some of0:50the default cursors that are built into0:52the operating system. Then we have0:54custom cursor where we can pick one of0:55our own components. And then we have set0:58variant, which requires a little bit1:00more setup. We're going to come back to1:01that one in just a little bit. But I'll1:03show you real quick that if I choose web1:04cursor, we get these familiar cursors1:07that are built into our operating system1:09that show up in various circumstances,1:11like when we hover over something that1:13can be grabbed and dragged or when we1:14hover over something that can be moved.1:16And these can be really useful,1:18especially if you're creating1:19interactions within your own components1:21and you want to give the visitor a1:22little signifier or affordance that1:25something can be clicked or can be1:27dragged. That's what the OS uses them1:29for in the first place. They're1:30contextual and they change depending on1:32what you're hovering the cursor over.1:34But because what we're trying to do here1:36is sort of get creative with the cursor1:39for the entire page, I'm not going to1:41choose one of these. We're going to do a1:43custom cursor instead. So I'm going to1:44close this. I'm going to rightclick on1:46our web cursor here and I'm going to1:48remove it. And I did do a small amount1:51of setup here. I have created components1:53for each of the cursors that we're going1:55to be setting throughout this particular1:57lesson. So if I scoot over to the left2:00just a little bit, you can see I've got2:01an instance of this component that's2:03really just a white dot. But if I double2:05click on it, I do have a pressed state2:07for that white dot. So if I preview2:09this, when we click down on the white2:11dot, it does get a little bit smaller.2:13And this press interaction actually will2:15work with our cursor. So we'll get that2:17extra little bit of tactile feedback2:20when we click the mouse down. So I'll go2:22back here and I'm going to go all the2:24way back to the homepage that we were on2:25before. And now with the desktop2:27breakpoint selected, I'll come back down2:29to cursor and this time I'll choose2:31custom cursor. And when I choose custom2:33cursor, I can choose from any one of the2:35components that are in this project. I'm2:37going to choose cursor dot. That's the2:39one we were just looking at. And then I2:40get to choose if I want that2:42cursor.component to follow the cursor or2:45replace the cursor. I'll start with2:47replace and I'll show you what follow2:48looks like in the next example. And then2:51the last property here is transition.2:53And what transition is going to do is2:55add a little bit of easing between the2:57input of moving the cursor around and3:00the actual cursor moving on the screen.3:02It kind of smooths out the movement.3:04When you're replacing a cursor, this can3:06feel a bit like input lag. it kind of3:08decouples your input from the visual3:11feedback that you're getting on the3:12screen. So, I'm not going to do that3:14with replace. I'll show you what that3:15looks like with follow in a moment. But3:18really, all I'm doing here is saying3:19anytime the cursor is within the desktop3:21breakpoint, replace the little arrow3:23with my cursor component. So, let's see3:26what that looks like. I'm going to press3:27command P on my Mac to go into preview3:29here. And there we go. Now, I have my3:32cursor component instead of my little3:35arrow. It's been replaced. And if I3:37click, I get that interaction that I3:38created within the component. So I get a3:40little visual feedback every time I3:42click the mouse. Now, let's say we don't3:44want to replace the default cursor. We3:47just want to add a little visual element3:49to spice things up a bit. So I'm going3:51to leave the preview here and I'm going3:53to head to the next page. And for this3:57example, you can see I've got a similar3:58sort of big white dot. And if I click4:01into this, you can see that I have a4:03press state where the dot gets a little4:04smaller. But the key thing with this is4:06that I've added a blending mode of4:08difference to the white dot here. And4:11what that's going to do is invert4:13whatever the white dot hovers over. Kind4:15of like a little X-ray that's floating4:17around following my cursor. So let me go4:19back to the canvas here and let's see it4:21in action. I'm going to select the4:22desktop breakpoint. Come back down here4:24to cursor. Add a custom cursor. And in4:27this case, I'm going to choose the4:29cursor inverted component. That's the4:31name that I happen to give this4:33component. And now the big distinction4:35here is instead of setting this to4:37replace, we're going to set this to4:39follow instead. And with follow, we get4:42quite a few extra settings cuz we get to4:44decide how the component that's4:46following the cursor around is going to4:48be positioned relative to the default4:50cursor. So I want it positioned relative4:53to the top of the default cursor. And I4:57want to align the center of the4:59component with the cursor. And the5:01offset is currently set to 0 0. But5:03let's see what that looks like as is.5:05I'm going to press command P to go into5:06preview mode here. And then here we go.5:09We've got the component aligned with the5:11top of the cursor and we've got it5:13centered up with the cursor pointer,5:15which is the very tip of the cursor. But5:17I kind of want the cursor to be in the5:19middle of the dot rather than the cursor5:21being at the bottom of the dot. So, I'm5:23going to go back and because the height5:25of that dot is about 60 pixels, I'm just5:28going to add a Y offset of 30 to move it5:31by half of its own height, which should5:33get us aligned with the middle of it.5:35The middle is half of the total height.5:37So, I'll press command P again. And5:39there we go. Now, the tip of the cursor5:41is aligned with the middle of the dot.5:43And as I mouse over, you can see that5:46we've got our difference blending mode5:48giving us that sort of X-ray effect. And5:50you'll also notice that the dot is kind5:52of trailing behind my cursor. It's5:54following, but it's following almost5:56kind of loosely. That's what the5:58transition property does. So, let's go6:00back. I'm going to leave preview mode6:02and let's head back over to the popover.6:03And you can see that there is in fact a6:06spring transition here. If I get rid of6:08that and we preview this again, see now6:10we have a very rigid relationship6:12between the position of the cursor and6:14the position of the component that's6:16following it. But you can really do what6:18you want with this. This is a creative6:19decision. We're not replacing the6:21cursor. So, we're not hijacking the6:23movement when we apply a transition that6:26adds a little bit of delay. That doesn't6:27translate to input lag because we still6:30have that one:one control over the6:32default cursor itself. The component6:34that's following it around, that's just6:36icing on the cake. So, now I'm going to6:38leave preview mode and I'm going to take6:40us to the third page to show you the6:42next example. Earlier I promised I would6:45show you what set cursor does. So in6:47this example, we're going to make the6:48cursor dynamically change and transition6:51from one cursor to another depending on6:54where we hover. So before we do that, I6:57want to give you a quick tour of the6:58component I created for this cursor7:00ahead of time. If I double click on this7:02guy, you can see that I've created a7:04cursor that starts off as a dot, but7:07then that dot can expand to reveal some7:10text. And we have a few different labels7:12here. where we have hover, press, loop,7:14and drag, which are kind of like little7:16tool tips that are going to describe the7:18things that we hover over. That's the7:21gist of the setup. So, I'm going to head7:22back to the canvas, and we're going to7:24start the same way that we always do.7:26I'm going to select the desktop7:27breakpoint, come down here, click to add7:30a cursor. We're going to do a regular7:32old custom cursor. And in this case,7:34we're going to make sure that we have7:35the right component selected. This one7:37is called cursor labels. And we're going7:40to start with the default variant, which7:42is going to replace the cursor, which7:44should just give us that dot. Let's7:45preview this. Let's make sure we're on7:46track. I'll press command P. And then7:48here we go. So, very much like the first7:51example we did. We are replacing the7:53cursor with a particular variant of a7:55component. Now, let's get fancy with it.7:57I'm going to go back. And now we're8:00going to go down to these little8:01elements here, which I would like to be8:03able to hover over and get a different8:05label depending on which one of these8:08we're hovering over. So we'll start with8:09the first one. With this particular8:11frame selected, I'm going to come back8:13over to the properties panel. I'm going8:15to add the cursor property again. And8:17now we have the option of set variant8:20because we have a component that has8:21variance set at the highest level, the8:24break point itself. So now we can get8:26more specific about elements that are8:28children of that breakpoint. So this8:30being one of them, I'm going to click8:32set variant. And here we get to choose8:35which variant it is we want to switch8:37to. Hover label is the one that I want8:40to use for this one. For the second one,8:42we'll use press. For the third one,8:43we'll use loop. And for the fourth one,8:45we'll use drag. But for this one, again,8:46hover. And that's it. We're just saying8:49switch to the hover variant when I hover8:52over this particular frame. So again,8:54we'll preview and I get my default8:56variant when I hover the cursor anywhere8:58over the break point except when I hover9:01the cursor over this particular frame.9:03And there we go. The cursor now switches9:06variants because these variants exist9:08within that component. And like the9:10interactive components we created9:11earlier in the course, Framer9:13automatically animates the transitions9:15from one variant to another. So we get9:18this awesome smooth transition from the9:20default cursor to the hover variant.9:22Now, let's combine what we did in the9:24last two examples and create a little9:26tool tip that follows the cursor around.9:29So, I'm going to leave the preview here9:31and I'm going to go back up and I'm9:33going to select the break point itself.9:35So, that way I can come back over here9:37and I can change this from replace to9:39follow. And for this one, I want the9:42tool tip to be to the right of the9:43cursor and aligned with the middle of it9:45sort of. I do want the tool tip to be9:47below and to the right of where the9:49cursor is. So, I'm going to make sure I9:51have this X offset of positive 20, which9:53is going to push it to the right, and9:54this Y offset of 20, which is going to9:56push it down. So, let's see where we're9:58at. I'm going to press command P to10:00preview this. And you can see that this10:02little dot following the cursor is to10:03the right of the cursor, and it's pushed10:05a little bit over and a little bit down10:07with the offset property. And if we10:09hover over this frame, there we go. We10:11get our full tool tip following the10:14cursor just a little bit down and to the10:16right. But this little dot is annoying.10:18We don't necessarily want a little dot10:20following the cursor all the time. So,10:21I'm going to go back and let's fix that10:23by going into the component itself and10:26adding a new variant. So, I'm going to10:29select this default variant here cuz10:31what I'm going to create is similar to10:32that. We're just not going to see the10:35white fill inside of the dot. And that's10:37easy enough. I'm just going to come down10:39here, find the fill property, click on10:41that, and bring the opacity all the way10:43down to zero. And then to make things a10:46little bit more clear for myself later,10:48I'm going to rename this variant hidden.10:51So now I can go back to the desktop10:53breakpoint and where I choose that10:55default cursor that's going to follow10:57around. Rather than using my default10:59variant, which was the white dot, I'm11:01going to use my new variant that I've11:02named hidden. And when I press command P11:05to preview, there we go. Now my cursor11:07is flying solo and I get my transition11:10to that hover variant when I hover over11:12this frame. So we're super close. Let's11:14just finish the job and add the tool11:16tips for these other frames. I'm going11:18to go back. I'm going to scroll down11:20just a little bit. And with this frame11:22selected, I'm going to add a cursor.11:24Choose set variant. Make sure that I11:26have the right variant selected, which11:28in this case is going to be press. And11:30then I'll add one to this third frame.11:32Set variant. Loop label. And this last11:36one is going to be my drag label11:38variant. So now we should be good to go.11:40I'll press command P. We've got our nice11:42clean cursor. And when we come down11:44here, we've got our little tool tips11:47that animate in and transition from one11:49to the other depending on where our11:51cursor is hovered. And there you have11:53it. Custom cursors can be informative,11:56add personality, and make our sites feel11:58more immersive. And now you know a few12:00different ways to go about it in Framer.12:03That's it for this one. I'll see you in12:05the next one.

Watch on YouTube ↗

More in this topic

Framer Update: Logo Shaders2:05
Framer Update: Logo Shaders
Framer Update12K views · 1 month ago
Framer Update: Holo Shader1:46
Framer Update: Holo Shader
Framer Update6K views · 2 months ago
Shader: Chromatic Aberration1:56
Shader: Chromatic Aberration
Framer Update7K views · 2 months ago
Framer Shaders2:28
Framer Shaders
Announcement23K views · 2 months ago
Framer Update: Flow Effect in Layout Templates2:12
Framer Update: Flow Effect in Layout Templates
Framer Update10K views · 3 months ago
Building an Expanding Article Stack in Framer13:14
Building an Expanding Article Stack in Framer
Animations4K views · 4 months ago
Scaling a clipped image on hover in Framer5:41
Scaling a clipped image on hover in Framer
Animations7K views · 5 months ago
Making elements revolve in Framer3:38
Making elements revolve in Framer
Animations5K views · 5 months ago

Create a free website with Framer, the website builder loved by startups, designers and agencies.