JSPM

shine-on-hover

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q45610F
  • License MIT

Lightweight, zero-dependency utility that adds a mouse-tracking shine effect on hover.

Package Exports

  • shine-on-hover

Readme

Shine on Hover

MIT Licence

Features

  • Lightweight < 3kb
  • No dependencies
  • Framework agnostic
  • Customizable

Installation

# npm
npm install shine-on-hover

# yarn
yarn add shine-on-hover

# pnpm
pnpm add shine-on-hover

# bun
bun add shine-on-hover

Usage

Vanilla JS

<div class="card" />
import { shine } from 'shine-on-hover';

shine('.card', {
  smooothness: 'BALANCE'
  shineColor: 'hsl(0deg 0% 0% / 4%)',
  shineSize: '5%',
  shineSpread: '50%',
  shineBorder: 'hsl(220deg 5% 88%)'
})

React

import { useEffect } from 'react';
import { shine } from 'shine-on-hover';

const Card = () => {
  useEffect(() => {
    shine('.card', {
      smooothness: 'BALANCE'
      shineColor: 'hsl(0deg 0% 0% / 4%)',
      shineSize: '5%',
      shineSpread: '50%',
      shineBorder: 'hsl(220deg 5% 88%)'
    })
  }, [])

  return <div className="card" />
}

Vue

<template>
    <div class="card" />
</template>

<script setup lang="ts">
import { onMounted } from 'vue';
import { shine } from 'shine-on-hover';

onMounted(() => {
  shine('.card', {
    smooothness: 'BALANCE'
    shineColor: 'hsl(0deg 0% 0% / 4%)',
    shineSize: '5%',
    shineSpread: '50%',
    shineBorder: 'hsl(220deg 5% 88%)'
  })
})
</script>

Svelte

<script lang="ts">
  import { onMount } from 'svelte';
  import { shine } from 'shine-on-hover';

  onMount(() => {
    shine('.card', {
      smooothness: 'BALANCE'
      shineColor: 'hsl(0deg 0% 0% / 4%)',
      shineSize: '5%',
      shineSpread: '50%',
      shineBorder: 'hsl(220deg 5% 88%)'
    })
  })
</script>

Configuration

Five properties are available to configure the shine effect:

Property Type Default Value Description
shineColor string hsl(0deg 0% 0% / 4%) The color of the shine effect.
shineSize string 5% The size of the shine effect.
shineSpread string 50% The spread of the shine effect.
shineBorder string transparent The color of the border of the shine effect.
smoooothness string BALANCE The smoothness of the shine effect.