A Stimulus controller that add a mouse-tracing glow effect.


  1. Install the package

    $ yarn add stimulus-glow
  2. Register the controller in your application

    import { Application } from '@hotwired/stimulus'
    import Glow from 'stimulus-glow'
    const application = Application.start()
    application.register('glow', Glow)

How it works

The concept of the effect is to clone an element, the overlay, and applying a CSS mask with a radia-gradiant property that follow the mouse.

Every element that has a glow class will be revealed by the mask but not the rest.


TailwindCSS is required to use this CSS, because we will use a custom variant to limit the glow effect to the overlay.

In your tailwind.config.js file, add this plugin:

const plugin = require('tailwindcss/plugin')

module.exports = {
  content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],

  plugins: [
      ({ addVariant }) => {
        addVariant('glow', '.glow-capture .glow-overlay &')
        theme: {
          extend: {
            colors: {
              glow: 'color-mix(in srgb, var(--glow-color) calc(<alpha-value> * 100%), transparent)',

Now in your CSS, add this class:

.glow-overlay {
  --glow-size: 25rem; /* Change the size of the glow effect here */

  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  opacity: var(--glow-opacity, 0);
  mask: radial-gradient(
    var(--glow-size) var(--glow-size) at var(--glow-x) var(--glow-y),
    var(--glow-color) 1%,
    transparent 50%
  transition: 400ms mask ease;
  will-change: mask;

Here is a simplified version of the minimum markup you need:

<div data-controller="glow" class="relative glow-capture">
  <div data-glow-target="child" class="glow glow:ring-1 glow:border-glow glow:ring-glow glow:bg-glow/[.15]">
    <h2 class="font-bold text-2xl mb-4 text-gray-200 glow:text-glow/[.8]">Chicken Shawarma & Veggies</h2>

    <p class="text-sm text-gray-300 glow:text-glow">Vitae ducimus harum earum ratione autem esse ea!</p>

    <button class="glow:text-glow glow:border-glow glow:ring glow:ring-glow">Add to cart</button>

  <div data-glow-target="overlay" class="glow-overlay" style="--glow-color: #f97316"></div>

I suggest you the inspect the index.html of the demo for a complete example.

Extending Controller

You can use inheritance to extend the functionality of any Stimulus component:

import Glow from 'stimulus-glow'

export default class extends Glow {
  connect() {
    console.log('Do what you want here.')

This controller will automatically have access to targets defined in the parent class.

If you override the connect, disconnect or any other methods from the parent, you'll want to call super.method() to make sure the parent functionality is executed.


Stimulus Component is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing. You can support Stimulus Components development on GitHub Sponsors. πŸ™


Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

Don't forget to drop a 🌟 on GitHub to support the project.


This project is released under the MIT license.