1rem
3.5rem

Shimmer Layer

Pure CSS to add an animated shimmer effect that activates on hover.

0px
Live Playground · Edit and see changes instantly
Or edit with AI support by
import {ShimmerLayer} from "@/components/phucbm/shimmer-layer";

export default function Example() {
    return (
        <div className="h-screen flex items-center justify-center gap-10 bg-slate-50">
            {/*button*/}
            <a
                href="#"
                className="group/shimmer overflow-hidden relative
                px-5 py-3 bg-blue-600 text-white rounded-lg text-sm
                border-t-[2px] border-x-[2px] border-b-[4px] border-black/15
                transition-all duration-300 ease-in-out
                hover:shadow-[0_4px_10px_rgba(0,0,0,0.08)] hover:bg-blue-600/90 hover:border-b-[2px]
                "
            >
                HOVER ON ME
                <ShimmerLayer/>
            </a>


            {/*image*/}
            <div
                className="w-56 aspect-square rounded-full group/shimmer relative overflow-hidden ring-1 ring-slate-300">
                <img src={`https://picsum.photos/400/400?random=${Math.random()}`}
                     alt="Image demo"
                     className="object-cover w-full h-full"/>
                <ShimmerLayer skew={-20} duration={1000} width={15}/>
            </div>

        </div>
    );
}

Installation

pnpm dlx shadcn@latest add @phucbm/shimmer-layer

Usage

The component uses CSS animations and gradient backgrounds to create a shimmer effect. It must be used inside an element with the group/shimmer class and overflow-hidden relative positioning.

group/shimmer overflow-hidden relative
<a href="#" className="group/shimmer overflow-hidden relative inline-flex items-center justify-center" > <span>Hover me</span> <ShiningLayer /> </a>

Props

NameTypeDefault
widthnumber

Width of each shine stripe in pixels.

10
skewnumber

Skew angle of the shine effect in degrees.

-12
durationnumber

Duration of the shine animation in milliseconds.

650
colorstring

Color of the shine effect.

"#fff"
3.5rem
1rem