Skip to content

Animated Buttons That Respect prefers-reduced-motion

What you'll learn: Learn how to disable decorative keyframe animation cleanly when the operating system reports prefers-reduced-motion, without breaking the button's function or layout.

The setting is a request, not a preference toggle

`prefers-reduced-motion: reduce` is reported by the operating system when a user has asked for less animation. It is not limited to one condition — it can be set for vestibular disorders, migraine sensitivity, or simple comfort. Browsers expose it as a media query, and CSS is the right place to honor it for decorative animation.

The important framing: the button must remain a button. Motion is decoration; the label, the click target, and the focus ring survive with every animation switched off.

The exact pattern used by the catalog

Nine buttons in the catalog ship their own reduced-motion block. The Coin Mint button is a compact example — it animates only while an `animating` class is present, and the media query removes the animation entirely:

  • Scoping the rule to the animated state class means the guard cannot accidentally freeze unrelated transitions.
  • `animation: none` renders the element as if the animation had never started; the end state of a decorative loop does not matter, which is why this is the right reset here.
Reduced-motion guard (Coin Mint, verbatim)
@media (prefers-reduced-motion: reduce) {
  .coin-mint-button.animating * {
    animation: none !important;
  }
}
Coin MintFull component →
Complete HTML + CSS
.coin-mint-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.coin-mint-button {
  position: relative;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border: none;
  border-radius: 0.75rem;
  color: #1f2937;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.coin-mint-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

.coin-icon {
  margin-right: 0.5rem;
  transition: transform 0.3s ease;
}

.coin-drop {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: #fbbf24;
  border-radius: 50%;
  opacity: 0;
}

.coin-mint-button.animating .coin-drop {
  animation: coin-drop 0.6s ease-out forwards;
}

@keyframes coin-drop {
  0% { top: -20px; opacity: 1; }
  70% { top: 20px; opacity: 1; }
  100% { top: 15px; opacity: 1; }
}

.coin-spin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  border-radius: 50%;
  opacity: 0;
}

.coin-mint-button.animating .coin-spin {
  animation: coin-spin 0.8s ease-in-out 0.6s forwards;
}

@keyframes coin-spin {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(360deg); opacity: 1; }
}

.coin-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 40px;
  height: 40px;
  border: 3px solid #059669;
  border-radius: 50%;
  opacity: 0;
}

.coin-mint-button.animating .coin-stamp {
  animation: coin-stamp 0.4s ease-out 1.4s forwards;
}

@keyframes coin-stamp {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.golden-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  opacity: 0;
}

.coin-mint-button.animating .golden-shine {
  animation: golden-shine 0.8s ease-in-out 1.8s forwards;
}

@keyframes golden-shine {
  0% { left: -100%; opacity: 0; }
  50% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

.receipt {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 20px;
  background: white;
  border-radius: 0 0 0.5rem 0.5rem;
  opacity: 0;
}

.coin-mint-button.animating .receipt {
  animation: receipt-appear 0.5s ease-out 2.2s forwards;
}

@keyframes receipt-appear {
  0% { bottom: -30px; opacity: 0; }
  100% { bottom: -10px; opacity: 1; }
}

.coin-mint-button.success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.coin-mint-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .coin-mint-button.animating * {
    animation: none !important;
  }
}

<div class="coin-mint-container">
  <button class="coin-mint-button" onclick="mintCoin()">
    <span class="coin-icon">🪙</span>
    <span class="button-text">Purchase</span>
    <div class="coin-drop"></div>
    <div class="coin-spin"></div>
    <div class="coin-stamp"></div>
    <div class="golden-shine"></div>
    <div class="receipt"></div>
  </button>
</div>

Loops vs. entrances need different resets

Decorative loops — embers, shimmer, melting — can simply be switched off, because their final frame is not meaningful. Entrance animations are different: if a panel animates in, removing the animation must not leave it invisible. For those, either animate from a visible base state, or collapse the duration instead of deleting the animation so the element still reaches its final state:

Safe entrance-animation reset
@media (prefers-reduced-motion: reduce) {
  .panel-enter {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Keep the motion inside the component

All three demos animate within the button's own box: the Ember button pulses its glow, the Lava button deforms its own surface with an inline SVG gooey filter, and the Coin button spins its face. Nothing moves the surrounding page. That containment matters — a looping full-viewport background is far more likely to be uncomfortable than a 40px icon spin, and it is also the more expensive thing to composite.

When you build your own, animate transform and opacity where possible, avoid animating `backdrop-filter` or large `filter` regions in a loop, and keep the reduced-motion guard next to the animation it disables so the two cannot drift apart.

Lava Melt ButtonFull component →
Complete HTML + CSS
.lava-goo-wrapper { position: relative; width: 200px; height: 65px; display: inline-block; }
.lava-goo-container { position: absolute; inset: 0; filter: url(#lava-gooey); z-index: 3; pointer-events: none; }
.lava-goo-bg { position: absolute; inset: 0; background: linear-gradient(180deg, #991b1b, #ef4444, #f59e0b); border-radius: 8px; cursor: pointer; pointer-events: auto; z-index: 1; transition: border-radius 0.4s ease; }
.lava-goo-wrapper:hover .lava-goo-bg { border-radius: 15px 15px 30px 30px; }
.lava-goo-drop { position: absolute; bottom: 5px; border-radius: 50%; opacity: 0; }
.lava-goo-wrapper:hover .lava-goo-drop { opacity: 1; }
.lava-goo-drop.d1 { width: 35px; height: 30px; left: 15%; background: #f59e0b; animation: lava-drip 3s infinite cubic-bezier(0.4,0,0.2,1) 0.2s; }
.lava-goo-drop.d2 { width: 20px; height: 20px; left: 50%; background: #ef4444; animation: lava-drip 3.5s infinite cubic-bezier(0.4,0,0.2,1) 1.2s; }
.lava-goo-drop.d3 { width: 40px; height: 35px; left: 75%; background: #f59e0b; animation: lava-drip 2.5s infinite cubic-bezier(0.4,0,0.2,1) 0s; }
.lava-goo-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; font-weight: 800; letter-spacing: 2px; z-index: 5; cursor: pointer; user-select: none; text-transform: uppercase; text-shadow: 0 2px 4px rgba(0,0,0,0.6); }
@keyframes lava-drip { 0% { transform: translateY(0) scaleX(1) scaleY(1); } 30% { transform: translateY(25px) scaleX(0.8) scaleY(1.4); } 70% { transform: translateY(80px) scaleX(0.6) scaleY(1.1); } 100% { transform: translateY(110px) scaleX(0) scaleY(0); } }
@media (prefers-reduced-motion: reduce) { .lava-goo-drop { animation: none !important; opacity: 0 !important; } }

<div class="lava-goo-wrapper">
  <svg style="position:absolute;width:0;height:0" aria-hidden="true">
    <defs>
      <filter id="lava-gooey">
        <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
        <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8" result="goo" />
        <feBlend in="SourceGraphic" in2="goo" />
      </filter>
    </defs>
  </svg>
  <div class="lava-goo-container">
    <div class="lava-goo-bg"></div>
    <div class="lava-goo-drop d1"></div>
    <div class="lava-goo-drop d2"></div>
    <div class="lava-goo-drop d3"></div>
  </div>
  <div class="lava-goo-text">Lava</div>
</div>

Test the off state, not just the on state

Emulate the setting in DevTools (Rendering → Emulate CSS prefers-reduced-motion) and reload. Confirm three things: the button still looks intentional, the label is readable, and the click target is unchanged. Then tab to it — focus must be visible with animation disabled.

The catalog's accessibility notes for these buttons make the same promise: the animation is decorative, the button remains fully clickable, and reduced motion disables the effect. Ship that promise, not just the media query.

Fire Ember ButtonFull component →
Complete HTML + CSS
.fire-goo-wrapper { position: relative; width: 200px; height: 65px; display: inline-block; }
.fire-goo-bg { position: absolute; inset: 0; background: linear-gradient(180deg, #ea580c, #facc15); border-radius: 8px; cursor: pointer; pointer-events: auto; z-index: 2; transition: box-shadow 0.3s ease; }
.fire-goo-wrapper:hover .fire-goo-bg { animation: fire-pulse 0.4s infinite alternate; }
.fire-particle { position: absolute; top: -5px; border-radius: 50%; filter: blur(3px); mix-blend-mode: screen; opacity: 0; z-index: 3; }
.fire-goo-wrapper:hover .fire-particle { opacity: 1; }
.fire-particle.p1 { width: 30px; height: 30px; left: 15%; background: #ef4444; animation: fire-flicker 0.8s infinite ease-in 0s; }
.fire-particle.p2 { width: 40px; height: 40px; left: 40%; background: #facc15; animation: fire-flicker 1.1s infinite ease-in 0.2s; }
.fire-particle.p3 { width: 35px; height: 35px; left: 65%; background: #ea580c; animation: fire-flicker 0.9s infinite ease-in 0.4s; }
.fire-particle.p4 { width: 20px; height: 20px; left: 85%; background: #facc15; animation: fire-flicker 0.7s infinite ease-in 0.1s; }
.fire-goo-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; font-weight: 800; letter-spacing: 2px; z-index: 5; cursor: pointer; user-select: none; text-transform: uppercase; text-shadow: 0 2px 4px rgba(0,0,0,0.6); }
@keyframes fire-flicker { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-70px) scale(0.1); opacity: 0; } }
@keyframes fire-pulse { 0% { box-shadow: 0 0 10px rgba(234,88,12,0.4); } 100% { box-shadow: 0 0 25px rgba(250,204,21,0.8); } }
@media (prefers-reduced-motion: reduce) { .fire-particle { animation: none !important; opacity: 0 !important; } .fire-goo-bg { animation: none !important; } }

<div class="fire-goo-wrapper">
  <div class="fire-goo-bg"></div>
  <div class="fire-particle p1"></div>
  <div class="fire-particle p2"></div>
  <div class="fire-particle p3"></div>
  <div class="fire-particle p4"></div>
  <div class="fire-goo-text">Fire</div>
</div>

Where to go next