Back to buttons
// MIT · BuildWithMe-UI contributors. Original implementation.
'use client';
import { useAnimation, type AnimationProps } from '../../shared/use-animation';
import '../../shared/base.css';
import './shimmer-button.css';

export default function ShimmerButton({
  paused = false,
  label = 'Make something great',
  onClick,
}: AnimationProps & { label?: string; onClick?: () => void }) {
  const { ref, active } = useAnimation(paused);
  return (
    <div ref={ref} className="bw-demo" data-active={active}>
      <button type="button" className="bw-button bw-shimmer" onClick={onClick}>
        {label}
      </button>
    </div>
  );
}

Shimmer Button

By purnavu-12

Try the interaction, copy the React source files, or download the complete example.

About Shimmer Button

Shimmer Button is an animated React and CSS button by purnavu-12. Try the interaction, copy the React source, or download the example with creator credit.

Effects and categories
Hover effects, Animated
Using this example
Copy a TSX file or download the original source and standalone demo. Test keyboard focus, motion and contrast in your own project.

Usage, Tailwind and licensing questions

Read the source files

registry/designs/shimmer-button/react.tsx

// MIT · BuildWithMe-UI contributors. Original implementation.
'use client';
import { useAnimation, type AnimationProps } from '../../shared/use-animation';
import '../../shared/base.css';
import './shimmer-button.css';

export default function ShimmerButton({
  paused = false,
  label = 'Make something great',
  onClick,
}: AnimationProps & { label?: string; onClick?: () => void }) {
  const { ref, active } = useAnimation(paused);
  return (
    <div ref={ref} className="bw-demo" data-active={active}>
      <button type="button" className="bw-button bw-shimmer" onClick={onClick}>
        {label}
      </button>
    </div>
  );
}

registry/shared/base.css

[data-bwm-theme='dark'] {
  --bwm-component-canvas: #050505;
  --bwm-component-panel: #10100f;
  --bwm-component-fg: #f4f1e8;
  --bwm-component-muted: #a6a49c;
  --bwm-component-border: #343431;
  --bwm-component-focus: #ffffff;
  --bwm-component-highlight: #d6ff59;
  --bwm-component-highlight-ink: #0b0d10;
  color-scheme: dark;
}
[data-bwm-theme='light'] {
  --bwm-component-canvas: #f3f0e8;
  --bwm-component-panel: #fcfaf3;
  --bwm-component-fg: #141412;
  --bwm-component-muted: #656159;
  --bwm-component-border: #cbc6ba;
  --bwm-component-focus: #0a0a09;
  --bwm-component-highlight: #244200;
  --bwm-component-highlight-ink: #ffffff;
  color-scheme: light;
}
.bw-demo {
  --bw-fg: var(--bwm-component-fg, #f4f1e8);
  --bw-muted: var(--bwm-component-muted, #a6a49c);
  --bw-panel: var(--bwm-component-panel, #10100f);
  --bw-border: var(--bwm-component-border, #343431);
  --bw-accent: var(--bwm-component-focus, #ffffff);
  --bw-bg: var(--bwm-component-canvas, #050505);
  --bw-line: var(--bwm-component-border, #343431);
  --bw-strong: var(--bwm-component-focus, #ffffff);
  --bw-highlight: var(--bwm-component-highlight, var(--bw-fg));
  --bw-highlight-ink: var(--bwm-component-highlight-ink, var(--bw-bg));
  color: var(--bw-fg);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  width: 100%;
  min-width: 0;
  position: relative;
  isolation: isolate;
  padding: 24px;
}
.bw-demo * {
  box-sizing: border-box;
}
.bw-demo button,
.bw-demo textarea,
.bw-demo input {
  font: inherit;
}
.bw-demo button {
  cursor: pointer;
}
.bw-demo button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}
.bw-demo :focus-visible {
  outline: 2px solid var(--bw-accent);
  outline-offset: 5px;
}
.bw-button {
  border: 1px solid var(--bw-border);
  background: var(--bw-panel);
  color: var(--bw-fg);
  padding: 13px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}
.bw-panel {
  background: var(--bw-panel);
  border: 1px solid var(--bw-border);
  border-radius: 16px;
  padding: 24px;
  width: min(100%, 310px);
  color: var(--bw-fg);
}
.bw-caption {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bw-muted);
  margin: 0 0 15px;
}
.bw-title {
  font-size: 24px;
  letter-spacing: -0.04em;
  font-weight: 550;
  margin: 0 0 10px;
}
.bw-description {
  font-size: 13px;
  line-height: 1.6;
  color: var(--bw-muted);
  margin: 0;
}
.bw-demo a {
  color: inherit;
}
.bw-demo input,
.bw-demo textarea,
.bw-demo select {
  color: var(--bw-fg);
  background: var(--bw-bg);
  border: 1px solid var(--bw-border);
  border-radius: 8px;
  padding: 12px;
  max-width: 100%;
}
.bw-demo input,
.bw-demo textarea {
  width: 100%;
}
:where(.bw-demo button) {
  color: inherit;
}
.bw-demo > * {
  min-width: 0;
}
.bw-demo pre {
  max-width: 100%;
  overflow-x: auto;
}
.bw-demo[data-active='false'] .bw-rotating > span {
  transform: none !important;
}
.bw-large-text {
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 550;
  letter-spacing: -0.05em;
  line-height: 1.15;
  margin: 0;
}
.bw-demo[data-active='false'] *,
.bw-demo[data-active='false'] *::before,
.bw-demo[data-active='false'] *::after {
  animation-play-state: paused !important;
}
@media (prefers-reduced-motion: reduce) {
  .bw-demo *,
  .bw-demo *::before,
  .bw-demo *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.bw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bw-demo input[type='radio'],
.bw-demo input[type='checkbox'] {
  width: auto;
  accent-color: var(--bw-highlight);
  margin-right: 8px;
}

.bw-demo[data-active='false'] .bw-tilt,
.bw-demo[data-active='false'] .bw-magnetic {
  transform: none !important;
  transition: none !important;
}

registry/shared/use-animation.ts

// MIT · BuildWithMe-UI contributors. Preserve this notice when redistributing.
'use client';
import { useEffect, useRef, useState } from 'react';
import { observeMotion } from './motion-lifecycle';
export type AnimationProps = { paused?: boolean };
/** Stops work when hidden, off screen, explicitly paused, or reduced motion is requested. */
export function useAnimation(paused = false) {
  const ref = useRef<HTMLDivElement>(null);
  const [active, setActive] = useState(false);
  const [reduced, setReduced] = useState(true);
  useEffect(() => {
    if (!ref.current) return;
    const lifecycle = observeMotion(
      ref.current,
      (state) => {
        setReduced(state.reduced);
        setActive(state.active);
      },
      paused,
    );
    return () => lifecycle.destroy();
  }, [paused]);
  return { ref, active, reduced };
}

registry/designs/shimmer-button/shimmer-button.css

.bw-shimmer {
  overflow: hidden;
  border-color: #5d644d;
}
.bw-shimmer:after {
  content: '';
  position: absolute;
  inset: -80%;
  background: linear-gradient(110deg, transparent 40%, #d5f5b333 50%, transparent 60%);
  animation: bw-shimmer 4s infinite;
  pointer-events: none;
}
@keyframes bw-shimmer {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(60%);
  }
}

registry/shared/motion-lifecycle.ts

// MIT · BuildWithMe-UI contributors. Preserve this notice when redistributing.
export type MotionState = { active: boolean; reduced: boolean };

/** Framework-neutral lifecycle for reviewed DOM effects; it never disables controls. */
export function observeMotion(
  element: HTMLElement,
  notify: (state: MotionState) => void,
  paused = false,
) {
  const doc = element.ownerDocument;
  const view = doc.defaultView;
  if (!view) return { setPaused: (_paused: boolean) => {}, destroy: () => {} };
  const media = view.matchMedia('(prefers-reduced-motion: reduce)');
  let visible = true;
  let stopped = false;
  let last = '';
  function update() {
    if (stopped) return;
    const state = {
      active:
        !paused && !media.matches && visible && !doc.hidden && doc.body.dataset.paused !== 'true',
      reduced: media.matches,
    };
    element.dataset.active = String(state.active);
    element.dataset.reduced = String(state.reduced);
    const key = `${state.active}:${state.reduced}`;
    if (key !== last) {
      last = key;
      notify(state);
    }
  }
  const visibility = new view.IntersectionObserver(([entry]) => {
    if (!entry) return;
    visible = entry.isIntersecting;
    update();
  });
  visibility.observe(element);
  const host = new view.MutationObserver(update);
  host.observe(doc.body, { attributes: true, attributeFilter: ['data-paused'] });
  media.addEventListener('change', update);
  doc.addEventListener('visibilitychange', update);
  update();
  return {
    setPaused(next: boolean) {
      paused = next;
      update();
    },
    destroy() {
      stopped = true;
      visibility.disconnect();
      host.disconnect();
      media.removeEventListener('change', update);
      doc.removeEventListener('visibilitychange', update);
    },
  };
}

demo.tsx

export { default as default } from "@/registry/designs/shimmer-button/react";

CSS

/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties;
@layer theme, base, components, utilities;
@layer theme {
  :root, :host {
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
      "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
      "Segoe UI Symbol", "Noto Color Emoji";
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
      "Courier New", monospace;
    --default-transition-duration: 150ms;
    --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    --default-font-family: var(--font-sans);
    --default-mono-font-family: var(--font-mono);
  }
}
@layer base {
  *, ::after, ::before, ::backdrop, ::file-selector-button {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid;
  }
  html, :host {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    font-family: var(--default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
    font-feature-settings: var(--default-font-feature-settings, normal);
    font-variation-settings: var(--default-font-variation-settings, normal);
    -webkit-tap-highlight-color: transparent;
  }
  hr {
    height: 0;
    color: inherit;
    border-top-width: 1px;
  }
  abbr:where([title]) {
    -webkit-text-decoration: underline dotted;
    text-decoration: underline dotted;
  }
  h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
  }
  a {
    color: inherit;
    -webkit-text-decoration: inherit;
    text-decoration: inherit;
  }
  b, strong {
    font-weight: bolder;
  }
  code, kbd, samp, pre {
    font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
    font-feature-settings: var(--default-mono-font-feature-settings, normal);
    font-variation-settings: var(--default-mono-font-variation-settings, normal);
    font-size: 1em;
  }
  small {
    font-size: 80%;
  }
  sub, sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  sub {
    bottom: -0.25em;
  }
  sup {
    top: -0.5em;
  }
  table {
    text-indent: 0;
    border-color: inherit;
    border-collapse: collapse;
  }
  :-moz-focusring:where(:not(iframe)) {
    outline: auto;
  }
  progress {
    vertical-align: baseline;
  }
  summary {
    display: list-item;
  }
  ol, ul, menu {
    list-style: none;
  }
  img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    vertical-align: middle;
  }
  img, video {
    max-width: 100%;
    height: auto;
  }
  button, input, select, optgroup, textarea, ::file-selector-button {
    font: inherit;
    font-feature-settings: inherit;
    font-variation-settings: inherit;
    letter-spacing: inherit;
    color: inherit;
    border-radius: 0;
    background-color: transparent;
    opacity: 1;
  }
  :where(select:is([multiple], [size])) optgroup {
    font-weight: bolder;
  }
  :where(select:is([multiple], [size])) optgroup option {
    padding-inline-start: 20px;
  }
  ::file-selector-button {
    margin-inline-end: 4px;
  }
  ::placeholder {
    opacity: 1;
  }
  @supports (not (-webkit-appearance: -apple-pay-button))  or (contain-intrinsic-size: 1px) {
    ::placeholder {
      color: currentcolor;
      @supports (color: color-mix(in lab, red, red)) {
        color: color-mix(in oklab, currentcolor 50%, transparent);
      }
    }
  }
  textarea {
    resize: vertical;
  }
  ::-webkit-search-decoration {
    -webkit-appearance: none;
  }
  ::-webkit-date-and-time-value {
    min-height: 1lh;
    text-align: inherit;
  }
  ::-webkit-datetime-edit {
    display: inline-flex;
  }
  ::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
  }
  ::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {
    padding-block: 0;
  }
  ::-webkit-calendar-picker-indicator {
    line-height: 1;
  }
  :-moz-ui-invalid {
    box-shadow: none;
  }
  button, input:where([type="button"], [type="reset"], [type="submit"]), ::file-selector-button {
    appearance: button;
  }
  ::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
    height: auto;
  }
  [hidden]:where(:not([hidden="until-found"])) {
    display: none !important;
  }
}
@layer utilities {
  .visible {
    visibility: visible;
  }
  .hidden {
    display: none;
  }
  .transform {
    transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
  }
  .border {
    border-style: var(--tw-border-style);
    border-width: 1px;
  }
  .outline {
    outline-style: var(--tw-outline-style);
    outline-width: 1px;
  }
  .transition {
    transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;
    transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
    transition-duration: var(--tw-duration, var(--default-transition-duration));
  }
}
:root {
  --background: #fff;
  --foreground: #111;
  --primary: #171717;
  --primary-foreground: #fff;
  --secondary: #eee;
  --secondary-foreground: #171717;
  --muted: #eee;
  --muted-foreground: #666;
  --accent: #eee;
  --accent-foreground: #171717;
  --border: #ddd;
  --input: #ddd;
  --ring: #777;
  --destructive: #dc2626;
  --destructive-foreground: #fff;
  --popover: #fff;
  --popover-foreground: #111;
  --success: #15803d;
  --success-foreground: #fff;
  --radius: .625rem;
  --hairline: 1px;
}
.dark {
  --background: #090909;
  --foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #171717;
  --secondary: #262626;
  --secondary-foreground: #fafafa;
  --muted: #262626;
  --muted-foreground: #a3a3a3;
  --accent: #262626;
  --accent-foreground: #fafafa;
  --border: #333;
  --input: #333;
  --popover: #171717;
  --popover-foreground: #fafafa;
}
:root, [data-theme='dark'] {
  --bg: #050505;
  --surface: #0b0b0b;
  --surface-2: #111;
  --ink: #f3f3ef;
  --muted: #8b8b87;
  --faint: #82827d;
  --line: #252525;
  --line-strong: #404040;
  --inverse: #050505;
  --paper: #f3f3ef;
  --bwm-component-canvas: #050505;
  --bwm-component-panel: #10100f;
  --bwm-component-fg: #f4f1e8;
  --bwm-component-muted: #a6a49c;
  --bwm-component-border: #343431;
  --bwm-component-focus: #ffffff;
  color-scheme: dark;
}
[data-bwm-theme='dark'] {
  --bwm-component-canvas: #050505;
  --bwm-component-panel: #10100f;
  --bwm-component-fg: #f4f1e8;
  --bwm-component-muted: #a6a49c;
  --bwm-component-border: #343431;
  --bwm-component-focus: #ffffff;
  --bwm-component-highlight: #d6ff59;
  --bwm-component-highlight-ink: #0b0d10;
  color-scheme: dark;
}
[data-bwm-theme='light'] {
  --bwm-component-canvas: #f3f0e8;
  --bwm-component-panel: #fcfaf3;
  --bwm-component-fg: #141412;
  --bwm-component-muted: #656159;
  --bwm-component-border: #cbc6ba;
  --bwm-component-focus: #0a0a09;
  --bwm-component-highlight: #244200;
  --bwm-component-highlight-ink: #ffffff;
  color-scheme: light;
}
.bw-demo {
  --bw-fg: var(--bwm-component-fg, #f4f1e8);
  --bw-muted: var(--bwm-component-muted, #a6a49c);
  --bw-panel: var(--bwm-component-panel, #10100f);
  --bw-border: var(--bwm-component-border, #343431);
  --bw-accent: var(--bwm-component-focus, #ffffff);
  --bw-bg: var(--bwm-component-canvas, #050505);
  --bw-line: var(--bwm-component-border, #343431);
  --bw-strong: var(--bwm-component-focus, #ffffff);
  --bw-highlight: var(--bwm-component-highlight, var(--bw-fg));
  --bw-highlight-ink: var(--bwm-component-highlight-ink, var(--bw-bg));
  color: var(--bw-fg);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  width: 100%;
  min-width: 0;
  position: relative;
  isolation: isolate;
  padding: 24px;
}
.bw-demo * {
  box-sizing: border-box;
}
.bw-demo button, .bw-demo textarea, .bw-demo input {
  font: inherit;
}
.bw-demo button {
  cursor: pointer;
}
.bw-demo button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}
.bw-demo :focus-visible {
  outline: 2px solid var(--bw-accent);
  outline-offset: 5px;
}
.bw-button {
  border: 1px solid var(--bw-border);
  background: var(--bw-panel);
  color: var(--bw-fg);
  padding: 13px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}
.bw-panel {
  background: var(--bw-panel);
  border: 1px solid var(--bw-border);
  border-radius: 16px;
  padding: 24px;
  width: min(100%, 310px);
  color: var(--bw-fg);
}
.bw-caption {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bw-muted);
  margin: 0 0 15px;
}
.bw-title {
  font-size: 24px;
  letter-spacing: -0.04em;
  font-weight: 550;
  margin: 0 0 10px;
}
.bw-description {
  font-size: 13px;
  line-height: 1.6;
  color: var(--bw-muted);
  margin: 0;
}
.bw-demo a {
  color: inherit;
}
.bw-demo input, .bw-demo textarea, .bw-demo select {
  color: var(--bw-fg);
  background: var(--bw-bg);
  border: 1px solid var(--bw-border);
  border-radius: 8px;
  padding: 12px;
  max-width: 100%;
}
.bw-demo input, .bw-demo textarea {
  width: 100%;
}
:where(.bw-demo button) {
  color: inherit;
}
.bw-demo > * {
  min-width: 0;
}
.bw-demo pre {
  max-width: 100%;
  overflow-x: auto;
}
.bw-demo[data-active='false'] .bw-rotating > span {
  transform: none !important;
}
.bw-large-text {
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 550;
  letter-spacing: -0.05em;
  line-height: 1.15;
  margin: 0;
}
.bw-demo[data-active='false'] *, .bw-demo[data-active='false'] *::before, .bw-demo[data-active='false'] *::after {
  animation-play-state: paused !important;
}
@media (prefers-reduced-motion: reduce) {
  .bw-demo *, .bw-demo *::before, .bw-demo *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
.bw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.bw-demo input[type='radio'], .bw-demo input[type='checkbox'] {
  width: auto;
  accent-color: var(--bw-highlight);
  margin-right: 8px;
}
.bw-demo[data-active='false'] .bw-tilt, .bw-demo[data-active='false'] .bw-magnetic {
  transform: none !important;
  transition: none !important;
}
.bw-shimmer {
  overflow: hidden;
  border-color: #5d644d;
}
.bw-shimmer:after {
  content: '';
  position: absolute;
  inset: -80%;
  background: linear-gradient(110deg, transparent 40%, #d5f5b333 50%, transparent 60%);
  animation: bw-shimmer 4s infinite;
  pointer-events: none;
}
@keyframes bw-shimmer {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(60%);
  }
}
@property --tw-rotate-x {
  syntax: "*";
  inherits: false;
}
@property --tw-rotate-y {
  syntax: "*";
  inherits: false;
}
@property --tw-rotate-z {
  syntax: "*";
  inherits: false;
}
@property --tw-skew-x {
  syntax: "*";
  inherits: false;
}
@property --tw-skew-y {
  syntax: "*";
  inherits: false;
}
@property --tw-border-style {
  syntax: "*";
  inherits: false;
  initial-value: solid;
}
@property --tw-outline-style {
  syntax: "*";
  inherits: false;
  initial-value: solid;
}
@layer properties {
  @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
    *, ::before, ::after, ::backdrop {
      --tw-rotate-x: initial;
      --tw-rotate-y: initial;
      --tw-rotate-z: initial;
      --tw-skew-x: initial;
      --tw-skew-y: initial;
      --tw-border-style: solid;
      --tw-outline-style: solid;
    }
  }
}