Buttons
ShimmerCTA
A light sheen sweeps across the button now and then. Catches the eye without shouting.
Download
- React
- Tailwind CSS v4
- motion
components/ui/shimmer-cta.tsx
"use client";
import type { ReactNode } from "react";
import { motion, useReducedMotion } from "motion/react";
type ShimmerCTAProps = {
children: ReactNode;
className?: string;
onClick?: () => void;
/** Colour of the sheen. */
shine?: string;
/** Seconds of rest between sweeps. */
every?: number;
};
/* ShimmerCTA: a light sheen sweeps across the button now and then, catching the eye without shouting. */
export function ShimmerCTA({
children,
className = "rounded-xl bg-[#2a2245] px-9 py-4 text-[15px] font-medium text-[#ede9fe] ring-1 ring-[#a78bfa]/40",
onClick,
shine = "rgba(255,255,255,0.35)",
every = 2.4,
}: ShimmerCTAProps) {
const reduce = useReducedMotion();
return (
<button type="button" onClick={onClick} className={`relative isolate overflow-hidden ${className}`}>
{!reduce && (
<motion.span
aria-hidden
className="pointer-events-none absolute inset-y-0 -left-1/2 w-1/2 -skew-x-12"
style={{ background: `linear-gradient(90deg, transparent, ${shine}, transparent)` }}
animate={{ x: ["0%", "320%"] }}
transition={{ duration: 1.1, repeat: Infinity, repeatDelay: every, ease: [0.4, 0, 0.2, 1] }}
/>
)}
<span className="relative">{children}</span>
</button>
);
}
1. Install the dependency.
npm i motion2. Paste the Code tab into
components/ui/shimmer-cta.tsx. The styles are Tailwind CSS v4 classes.3. Use it. This is the preview above:
app/shimmer-cta-demo.tsx
import { ShimmerCTA } from "@/components/ui/shimmer-cta"; export default function ShimmerCTAExample() { return ( <div className="grid h-full place-items-center bg-[radial-gradient(circle_at_50%_60%,#1d1a33,#0d0c14_70%)]"> <ShimmerCTA>Get the bundle</ShimmerCTA> </div> ); }
Props
| Name | Type | Default | What it does |
|---|---|---|---|
| children | ReactNode | — | Button label. |
| onClick | () => void | — | Click handler. |
| shine | string | "rgba(255,255,255,0.35)" | Colour of the sheen. |
| every | number | 2.4 | Seconds of rest between sweeps. |
| className | string | dark violet block | Replaces the default look. |