text spotlight cursor

How we can create an attractive spotlight hover or mouser over effect? Solution: See this Text Spotlight Cursor Hover Effect With GSAP, Spotlight Mask Over Text.

Previously I have shared a text mask effect, it is a little similar to that but there is much different because there is a spotlight effect. Basically, A spotlight is a powerful stage lighting instrument that projects a bright beam of light onto a selected space. But we can create and use this kind of effect for web elements also, for showing selected or focused items.

Today you will learn to create Spotlight Mask Over Texts. Basically, there is a text and circular spotlight with 3 different colors. The spotlight color arranged in a circular form, like smaller circles in front and bigger ones in the back. Because with this arrangement, we can see all 3 circles. Also, there is another circle for showing the mouse pointer and it placed in the middle of the spotlight circle group. Now the spotlight will move according to mouse direction, but you can see the light over the text because there is a kind of masking effect.

So, Today I am sharing Text Spotlight Cursor Hover Effect With GSAP. Greensock Animation API, as known as GSAP is an animation library that helps you create performant animations. It is a JavaScript library that enables front-end developers and designers. Because of this is a JS library, that’s why I am putting this program in the JavaScript category.

If you are thinking now how this animated cursor actually is, then see the preview given below.

Preview Of GSAP Spotlight Mask Over Texts

See this video preview to getting an idea of how this spotlight effect looks like.

Live Demo

Now you can see this visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.

You May Also Like:

Text Spotlight Cursor Hover Effect Source Code

Before sharing source code, let’s talk about it. First I have created a div for creating the cursor, and another div with 3 divs set for creating the spotlight, and finally created a div for the text. Also in the HTML file, I have linked other files like CSS, JS, and GSAP CDN. Inside the spotlight divs group, I have placed a similar class name in all divs and a unique for identifying each.

Now using CSS I have placed all the elements in the right place, as you can see in the preview. With CSS. I have done basic works like size, position, margin, padding, etc. I gave different colors for the spotlight divs for proper visual, and styled the cursor div which I have created at first. Now I gave a selection color by giving values in CSS ::selection command.

There is few lines of codes in the JS file, because this program is based on a library. GSAP first detects the mouse movement using .addEventListener command, and the cursor div as the mouse pointer. After that stuck the spotlight shapes around the mouse cursor using its pre-built functions.

Left all other things you will understand after getting the codes, I can’t explain all in writing. For creating this program you have to create 3 files. First file for HTML, second for CSS, and the third file for JavaScript. Follow the steps to creating this without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes given here.

function.js

The final step, create a JavaScript file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created Text Spotlight Cursor Hover Effect With GSAP, Spotlight Mask Over Text. If you have any doubt or questions comment down below.

Thanks For Visiting, Keep Visiting.

LEAVE A REPLY

Please enter your comment!
Please enter your name here