Over 10 years we helping companies reach their financial and branding goals. Onum is a values-driven SEO agency dedicated.

CONTACTS
HTML & CSS

Glowing Neon Cursor – Step-by-Step Tutorial

Introduction

Have you ever seen a glowing neon cursor on a website and wondered how it was made?
In this tutorial, we’ll create a glowing neon cursor effect using Three.js Toys.
It’s smooth, interactive, and lightweight – perfect for portfolios, blogs, or any creative website.

By the end of this guide, you’ll have a fully functional neon cursor on your site, and you’ll know how to customize it!


Step 1: HTML Setup

Create an index.html file and paste the following code:

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>Glowing Neon Cursor | Lear New Things</title>
  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Montserrat:wght@500;700&display=swap'><link rel="stylesheet" href="./style.css">

</head>
<body>

<div id="app">
  <div id="hero">
    <h1>NEON<br/>CURSOR</h1>
    <p>@learnnewthings_25</p>
  </div>
</div>

  <script type="module" src="./script.js"></script>

</body>
</html>

Explanation:

  • We set up a container #app that will hold our neon cursor effect.
  • Included a Google Font Montserrat for stylish text.
  • Linked our CSS and JS files.

Step 2: CSS Styling

Create style.css and paste this code:

body, html, #app {
  margin: 0;
  width: 100%;
  height: 100%;
}

#app {
  overflow: hidden;
  touch-action: pan-up;
  color: #ffffff;
  font-family: 'Montserrat', sans-serif;
  text-align: center;
  text-shadow: 0 0 5px #ffffff, 0 0 20px #000, 0 0 30px #000;
}

#app h1 {
  --fontSize: 60px;
  --lineHeight: 80px;
  width: auto;
  height: calc(2 * var(--lineHeight));
  line-height: var(--lineHeight);
  margin: calc(50vh - var(--lineHeight)) auto 0;
  font-size: var(--fontSize);
  text-transform: uppercase;
}

#app p {
  margin-top: 10px;
  display: inline-block;
  text-decoration: none;
  color: #fff;
}

#app canvas {
  display: block;
  position: fixed;
  z-index: -1;
  top: 0;
}

Explanation:

  • Styles the container to cover full screen and center text.
  • text-shadow gives a glowing neon effect to text.
  • canvas is positioned behind everything for the neon cursor trails.

Step 3: JavaScript (Neon Cursor)

Create script.js and paste the following:

import { neonCursor } from 'https://unpkg.com/threejs-toys@0.0.8/build/threejs-toys.module.cdn.min.js'

neonCursor({
  el: document.getElementById('app'),
  shaderPoints: 16,
  curvePoints: 80,
  curveLerp: 0.5,
  radius1: 5,
  radius2: 30,
  velocityTreshold: 10,
  sleepRadiusX: 100,
  sleepRadiusY: 100,
  sleepTimeCoefX: 0.0025,
  sleepTimeCoefY: 0.0025
})

Explanation:

  • We import neonCursor from Three.js Toys.
  • Cursor trails follow the mouse with glowing neon effect.
  • You can customize radius, curve smoothness, and speed.

Step 4: How It Works

  1. The cursor follows your mouse movement.
  2. Smooth curves are created using curvePoints and curveLerp parameters.
  3. Neon effect is achieved by using shader points and text-shadow.
  4. You can easily tweak radius, speed, or colors for your personal style.

Step 5: Live Demo & Download

  • Live Demo: https://github.com/rukeshbabugantla143/Glowing-Neon-Cursor.git
  • Download Code: GitHub Repository

Conclusion

With just a few lines of HTML, CSS, and JS, you can make a glowing neon cursor that adds style and interactivity to your website.
Experiment with different colors, shadows, and speeds to make it uniquely yours!

Leave a comment

Your email address will not be published. Required fields are marked *