jackyef / cursor-flashlight

A tiny library to add flashlight effect to your website πŸ”¦

Home Page:https://codesandbox.io/s/w8o5t

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minified-gzipped-size

cursor-flashlight πŸ”¦

A tiny library to add flashlight effect to your website πŸ”¦

Try it on CodeSandbox

demo

Note: The effect won't show on devices without mouse (e.g.: smartphones)

Usage

Simply import the module and enable the flashlight with the size of the flashlight circle.

import { enable } from 'cursor-flashlight';

enable({ size: '15vmax' });

Example with React

import React from 'react';
import {
  enable,
  disable,
  isEnabled,
} from 'cursor-flashlight';

const App = () => {
  const handleToggleFlashlight = () => {
    if (isEnabled()) {
      disable()
    } else {
      enable({ size: '15vmax' })
    }
  }

  return (
    <div>
      Lorem ipsum stuffs
      <button onClick={handleToggleFlashlight}>Toggle flashlight</button>
    </div>
  )
};

About

A tiny library to add flashlight effect to your website πŸ”¦

https://codesandbox.io/s/w8o5t


Languages

Language:HTML 48.6%Language:TypeScript 37.7%Language:JavaScript 13.7%