Skip to content

Shimmer Button

Shimmer button for React: a dark capsule with a travelling light sweep and rotating border glow, built for one main CTA.

  • Buttons
  • AI / SaaS
  • React only · 0 deps
  • 1 file
Full screen

Browser support · Rotating ring uses @property (Chrome, Edge, Safari 16.4+, Firefox 128+); older browsers show a static ring.

Install. One command, or copy the file.

$npx shadcn@latest add https://freedesignmd.com/r/shimmer-button.json
  • Byte-identical to the preview
  • No Tailwind or config needed
  • SSR-safe · keyboard accessible
  • Respects reduced motion & transparency
components/buttons/shimmer-button.tsx
1/**
2 * ShimmerButton, dark capsule with a travelling light sweep and a rotating
3 * border glow. Built for single, high-intent calls to action.
4 *
5 * Props: size ("sm" | "md" | "lg"), iconRight, speed (seconds per sweep,
6 * default 3.2), theme ("light" | "dark" | inherits [data-fd-theme]), plus every
7 * native <button> prop. CSS vars: --fd-shim-bg, --fd-shim-glow, --fd-shim-radius.
8 *
9 * Browser support: sweep works everywhere; the rotating ring uses @property
10 * (Chrome, Edge, Safari 16.4+, Firefox 128+) and degrades to a static ring.
11 * Accessibility: native <button>, visible focus ring, effects are
12 * aria-hidden. Reduced motion: sweep and ring animation are removed.
13 */
14import { forwardRef, useState } from "react";
15import type { ButtonHTMLAttributes, ReactNode } from "react";
16
17export interface ShimmerButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
18 size?: "sm" | "md" | "lg";
19 iconRight?: ReactNode;
20 speed?: number;
21 theme?: "light" | "dark";
22}
23
24export const ShimmerButton = forwardRef<HTMLButtonElement, ShimmerButtonProps>(function ShimmerButton(
25 { size = "md", iconRight, speed = 3.2, theme, className, style, children, type = "button", ...rest },
26 ref,
27) {
28 return (
29 <>
30 <style>{css}</style>
31 <button
32 ref={ref}
33 type={type}
34 className={`fd-shim${className ? " " + className : ""}`}
35 data-size={size}
36 data-fd-theme={theme}
37 style={{ ["--fd-shim-speed" as string]: `${speed}s`, ...style }}
38 {...rest}
39 >
40 <span className="fd-shim-ring" aria-hidden="true" />
41 <span className="fd-shim-sweep" aria-hidden="true" />
42 <span className="fd-shim-content">
43 <span className="fd-shim-label">{children}</span>
44 {iconRight && <span className="fd-shim-icon">{iconRight}</span>}
45 </span>
46 </button>
47 </>
48 );
49});
50
51const css = `
52:where(.fd-shim,.fd-shim *){box-sizing:border-box;margin:0;padding:0;font:inherit;letter-spacing:inherit;color:inherit;text-decoration:none;list-style:none}
53:where(.fd-shim,.fd-shim *)::before,:where(.fd-shim,.fd-shim *)::after{box-sizing:border-box}
54:where(.fd-shim svg){display:block;flex-shrink:0}
55@property --fd-shim-a{syntax:"<angle>";inherits:false;initial-value:0deg}
56.fd-shim{
57 --fd-ease-out:cubic-bezier(.22,1,.36,1);--fd-spring:cubic-bezier(.34,1.56,.64,1);--fd-dur-1:120ms;--fd-dur-2:240ms;--fd-dur-3:420ms;
58 --fd-shim-bg:#0B0B0F;--fd-shim-fg:#F5F5F7;--fd-shim-edge:rgba(255,255,255,.14);--fd-shim-glow:255,255,255;--fd-shim-radius:9999px;
59 --s-shadow:0 1px 0 rgba(255,255,255,.1) inset,0 1px 2px rgba(11,11,15,.3),0 12px 28px -12px rgba(11,11,15,.55);
60 position:relative;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;overflow:hidden;isolation:isolate;
61 appearance:none;-webkit-appearance:none;border:0;outline:0;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;
62 background:var(--fd-shim-bg);color:var(--fd-shim-fg);border-radius:var(--fd-shim-radius);
63 font:500 15px/1 ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,sans-serif;letter-spacing:-.005em;
64 box-shadow:0 0 0 1px var(--fd-shim-edge),var(--s-shadow);
65 transform:scale(1);transition:transform var(--fd-dur-3) var(--fd-spring),box-shadow var(--fd-dur-2) var(--fd-ease-out);
66}
67[data-fd-theme="dark"] .fd-shim,.fd-shim[data-fd-theme="dark"]{--fd-shim-bg:#1F1F27;--fd-shim-edge:rgba(255,255,255,.16);--s-shadow:0 1px 0 rgba(255,255,255,.08) inset,0 1px 2px rgba(0,0,0,.5),0 12px 32px -12px rgba(0,0,0,.8)}
68.fd-shim[data-size="sm"]{height:32px;padding:0 14px;font-size:13px}
69.fd-shim[data-size="md"]{height:40px;padding:0 20px;font-size:15px}
70.fd-shim[data-size="lg"]{height:52px;padding:0 28px;font-size:17px;letter-spacing:-.01em}
71.fd-shim-content{position:relative;z-index:2;display:inline-flex;align-items:center;gap:8px}
72.fd-shim-label{display:block;white-space:nowrap}
73.fd-shim-icon{display:grid;place-items:center;width:18px;height:18px;transition:transform var(--fd-dur-2) var(--fd-ease-out)}
74.fd-shim-icon svg{width:100%;height:100%}
75.fd-shim-sweep{position:absolute;z-index:1;top:0;bottom:0;left:0;width:45%;pointer-events:none;
76 background:linear-gradient(100deg,transparent 0%,rgba(var(--fd-shim-glow),.0) 20%,rgba(var(--fd-shim-glow),.22) 50%,rgba(var(--fd-shim-glow),0) 80%,transparent 100%);
77 transform:translateX(-120%) skewX(-18deg);animation:fd-shim-sweep var(--fd-shim-speed,3.2s) var(--fd-ease-out) infinite}
78.fd-shim-ring{position:absolute;inset:0;z-index:1;border-radius:inherit;padding:1px;pointer-events:none;
79 background:conic-gradient(from var(--fd-shim-a),transparent 0deg,transparent 250deg,rgba(var(--fd-shim-glow),.9) 320deg,transparent 360deg);
80 -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);
81 animation:fd-shim-spin calc(var(--fd-shim-speed,3.2s) * 1.6) linear infinite;opacity:.8;transition:opacity var(--fd-dur-2) var(--fd-ease-out)}
82@media (hover:hover){
83 .fd-shim:hover{box-shadow:0 0 0 1px rgba(var(--fd-shim-glow),.22),var(--s-shadow),0 0 28px -4px rgba(var(--fd-shim-glow),.28)}
84 .fd-shim:hover .fd-shim-ring{opacity:1}
85 .fd-shim:hover .fd-shim-icon{transform:translateX(2px)}
86}
87.fd-shim:active{transform:scale(.96);transition:transform var(--fd-dur-1) var(--fd-ease-out),box-shadow var(--fd-dur-2) var(--fd-ease-out)}
88.fd-shim:focus-visible{outline:2px solid rgba(10,132,255,.8);outline-offset:2px}
89.fd-shim:disabled{opacity:.5;cursor:not-allowed;transform:none}
90.fd-shim:disabled .fd-shim-sweep,.fd-shim:disabled .fd-shim-ring{animation:none;opacity:0}
91@keyframes fd-shim-sweep{0%{transform:translateX(-120%) skewX(-18deg)}55%,100%{transform:translateX(320%) skewX(-18deg)}}
92@keyframes fd-shim-spin{to{--fd-shim-a:360deg}}
93@media (prefers-reduced-motion:reduce){
94 .fd-shim,.fd-shim:active{transition:box-shadow var(--fd-dur-1) linear;transform:none}
95 .fd-shim-sweep{display:none}
96 .fd-shim-ring{animation:none;--fd-shim-a:300deg;opacity:.6}
97 .fd-shim-icon{transition:none}
98}
99@media (prefers-contrast:more){.fd-shim{box-shadow:0 0 0 1px currentColor}}
100`;
101
102/* ───────────────────────────── demo ───────────────────────────── */
103
104const arrow = (
105 <svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14M13 6l6 6-6 6" /></svg>
106);
107
108export function Demo() {
109 return (
110 <div className="fd-shimd">
111 <style>{demoCss}</style>
112 <ShimmerButton size="lg" iconRight={arrow} theme="dark">Join the waitlist</ShimmerButton>
113 </div>
114 );
115}
116
117const demoCss = `
118.fd-shimd,.fd-shimd *,.fd-shimd *::before,.fd-shimd *::after{box-sizing:border-box}
119.fd-shimd{display:flex;align-items:center;justify-content:center;min-height:100vh;width:100%;margin:0;padding:32px 20px;overflow:hidden;background:#f4f4f4;color:#1d1d1f;font:400 15px/1.4 ui-sans-serif,-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,sans-serif;letter-spacing:normal;-webkit-font-smoothing:antialiased}
120`;

More Buttons. Same file contract.

Button Core, buttons preview: React button component with 5 variants, 3 sizes, icon slots, a loading to success morph and a springy press

Button Core

React button component with 5 variants, 3 sizes, icon slots, a loading to success morph and a springy press.

Magnetic Button, buttons preview: Magnetic button for React that leans toward your cursor on a spring, with the label drifting further than the…

Magnetic Button

Magnetic button for React that leans toward your cursor on a spring, with the label drifting further than the shell.

Hold to Confirm, buttons preview: Hold to confirm button for destructive actions: progress fills while you press, early release cancels, Space…

Hold to Confirm

Hold to confirm button for destructive actions: progress fills while you press, early release cancels, Space works too.

Questions about Shimmer Button

Run npx shadcn@latest add https://freedesignmd.com/r/shimmer-button.json, or open the page and copy the file into your project. It has zero dependencies besides React. What you copy is the exact file that renders the live demo.

Shimmer button for React: a dark capsule with a travelling light sweep and rotating border glow, built for one main CTA. It is a free, MIT-licensed React buttons component from the freedesignmd library.

Yes. It is free and MIT-licensed, use, modify and ship it in personal and commercial projects without attribution.

Rotating ring uses @property (Chrome, Edge, Safari 16.4+, Firefox 128+); older browsers show a static ring.

Yes. It is a plain React component with its own styles, so it runs in Next.js, Vite, Remix and Lovable projects, and it needs no Tailwind setup. It has zero dependencies besides React.