October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
ThatPainter
CSS

10 Simple CSS and JavaScript Micro-interactions for Buttons

Learn how to build 10 useful button micro-interactions with semantic HTML, CSS, and small JavaScript snippets—without sacrificing keyboard, touch, screen-reader, or reduced-motion support.

By ThatPainter Team 8 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ThatPainter is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Learn More

Button micro-interactions are small responses—color changes, movement, loading labels, or status messages—that tell users what happened after they interact. The best effects provide feedback without delaying the action, shifting the layout, or replacing accessible text.

These examples use native HTML buttons, plain CSS, and small JavaScript snippets. Treat hover and animation as enhancements: keyboard focus, touch behavior, semantic states, and clear success or error messages matter more than visual polish.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start with a real, accessible button

Use <button> for an action in the current page and an <a> element for navigation. Native buttons already support keyboard activation with Enter and Space. Use type="button" when the button must not submit a form, and type="submit" for a form submission. See the WAI-ARIA button pattern for button, toggle, menu, and focus guidance.

<button class="btn" type="button">
  <span class="btn__label">Save changes</span>
</button>
.btn {
  --btn-bg: #2563eb;
  --btn-bg-hover: #1d4ed8;
  --btn-text: #fff;
  --btn-ring: #93c5fd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-block-size: 2.75rem;
  padding: .7rem 1rem;
  border: 0;
  border-radius: .5rem;
  background: var(--btn-bg);
  color: var(--btn-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease,
              transform 160ms ease, color 160ms ease;
}

.btn:hover { background: var(--btn-bg-hover); }
.btn:focus-visible {
  outline: 3px solid var(--btn-ring);
  outline-offset: 3px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .6;
}

:hover is a pointer preview, :focus-visible indicates keyboard position, :active is transient press feedback, and classes such as .is-loading or .is-success represent application state. Do not use focus as proof that an action succeeded.

#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

1. Smooth hover color and elevation

This gives pointer users an immediate indication that the control is interactive. It is supplemental and must not be the only feedback because touchscreens do not provide reliable hover.

<button class="btn btn--lift" type="button">Get started</button>
.btn--lift:hover {
  background: #1d4ed8;
  box-shadow: 0 .5rem 1rem rgb(15 23 42 / .18);
  transform: translateY(-2px);
}
.btn--lift:active {
  box-shadow: 0 .2rem .35rem rgb(15 23 42 / .18);
  transform: translateY(0);
}

Keep the movement subtle. If the button is frequently used on a touch device, the color and pressed states should still make sense without hover.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Keyboard-only focus ring

A visible focus indicator is essential for keyboard users. Never remove the browser outline without replacing it with a clear, high-contrast style. W3C provides a :focus-visible focus example.

<button class="btn btn--focus" type="button">Continue</button>
.btn--focus:focus { outline: none; }
.btn--focus:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgb(245 158 11 / .25);
}

Test by clicking elsewhere, pressing Tab until the button is focused, then activating it with Enter and Space. Check the ring against every background and at high zoom.

Rank #2
Sale
Logitech M240 Compact Silent Bluetooth Wireless Mouse - Graphite
  • Pair and Play: With fast, easy Bluetooth wireless technology, you’re connected in seconds to this quiet cordless mouse —no dongle or port required
  • Less Noise, More Focus: Silent mouse with 90% reduced click sound and the same click feel, eliminating noise and distractions for you and others around you (1)
  • Long-Lasting Battery Life: Up to 18-month battery life with an energy-efficient auto sleep feature, so you can go longer between battery changes (2)
  • Comfortable, Travel-Friendly Design: Small enough to toss in a bag; this slim and ambidextrous portable compact mouse guides either your right or left hand into a natural position
  • Long-Range: Reliable, long-range Bluetooth wireless mouse works up to 10m/33 feet away from your computer (3)

3. Press-down physical feedback

A short downward movement makes activation feel immediate without changing layout dimensions.

<button class="btn btn--press" type="button">Press me</button>
.btn--press {
  box-shadow: 0 4px 0 #1e3a8a;
  transform: translateY(0);
  transition: transform 100ms ease, box-shadow 100ms ease;
}
.btn--press:active {
  box-shadow: 0 1px 0 #1e3a8a;
  transform: translateY(3px);
}

Do not animate width, height, margins, or other layout-affecting properties. Test both mouse clicks and keyboard activation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Ripple from the pointer position

A ripple can show where a pointer pressed, particularly on a large touch target. It should never be the only activation confirmation.

<button class="btn btn--ripple" type="button">Get started</button>
.btn--ripple { position: relative; overflow: hidden; isolation: isolate; }
.btn--ripple::after {
  content: "";
  position: absolute;
  inline-size: 1rem;
  block-size: 1rem;
  border-radius: 50%;
  background: rgb(255 255 255 / .45);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}
.btn--ripple.is-rippling::after {
  animation: ripple 500ms ease-out;
}
@keyframes ripple {
  from { opacity: .8; transform: translate(var(--ripple-x), var(--ripple-y)) scale(0); }
  to { opacity: 0; transform: translate(var(--ripple-x), var(--ripple-y)) scale(18); }
}
document.querySelectorAll(".btn--ripple").forEach((button) => {
  button.addEventListener("pointerdown", (event) => {
    const rect = button.getBoundingClientRect();
    button.style.setProperty("--ripple-x", `${event.clientX - rect.left}px`);
    button.style.setProperty("--ripple-y", `${event.clientY - rect.top}px`);
    button.classList.remove("is-rippling");
    void button.offsetWidth;
    button.classList.add("is-rippling");
  });
  button.addEventListener("animationend", () => {
    button.classList.remove("is-rippling");
  });
});

pointerdown supplies coordinates but should not replace the button’s normal click or form-submission behavior. Also check that overflow: hidden does not clip an external focus ring. For keyboard activation, use a centered ripple or omit it.

Rank #3
Afaartcci Rechargeable Wireless Mouse, Silent Bluetooth Mouse (Black)
  • 【Dual Mode Wireless Bluetooth Mouse】: Switch easily between two devices—connect one via Bluetooth (BT5.2/3.0) and the other using a 2.4G USB receiver. No drivers needed; just plug and play. Enjoy a reliable connection up to 33 feet. Note: You can't use both modes simultaneously; the USB receiver is stored in the mouse.
  • 【Rechargeable Wireless Mouse】: Equipped with a 500mAh lithium-ion battery, it charges in 2 hours for over 7 days of use and 30 days on standby. The mouse sleeps after 5 minutes of inactivity to save power and can be woken with any click.
  • 【Colorful LED Breathing Light】: Features 7 colorful LED lights that change randomly, adding a fun atmosphere to your workspace.
  • 【Portable Mouse】Compact size (4.4 x 2.3 x 1.1 inches) makes it easy to fit in your laptop bag. Lightweight and ergonomic, it's perfect for travel. Contact us anytime for support.
  • 【Wide Compatibility】: Works with laptops, PCs, tablets, and smartphones across various operating systems, including Android, Windows, and Mac. Ideal for home, office, and travel.

5. Arrow or icon nudge

Movement is most useful when it reinforces meaning. An arrow moving toward the destination supports actions such as Continue or View details.

<button class="btn btn--arrow" type="button">
  <span>Continue</span>
  <span class="btn__arrow" aria-hidden="true">→</span>
</button>
.btn--arrow .btn__arrow { transition: transform 160ms ease; }
.btn--arrow:hover .btn__arrow,
.btn--arrow:focus-visible .btn__arrow {
  transform: translateX(.25rem);
}

The icon is decorative because the text already names the action, so it is hidden from assistive technology. Avoid random movement that communicates nothing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Loading state after activation

Use a loading state for asynchronous work. It communicates that the action has started and, for duplicate-sensitive operations, prevents repeated submissions.

<button class="btn btn--loading" type="button">
  <span class="btn__label">Save changes</span>
  <span class="btn__spinner" aria-hidden="true"></span>
</button>
.btn--loading .btn__spinner {
  display: none;
  inline-size: 1rem;
  block-size: 1rem;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.btn--loading.is-loading .btn__spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
async function save(button) {
  if (button.disabled) return;
  const label = button.querySelector(".btn__label");
  const original = label.textContent;
  button.disabled = true;
  button.setAttribute("aria-busy", "true");
  button.classList.add("is-loading");
  label.textContent = "Saving…";
  try {
    await fakeRequest();
    label.textContent = "Saved";
  } catch {
    label.textContent = "Try again";
  } finally {
    button.classList.remove("is-loading");
    button.removeAttribute("aria-busy");
    button.disabled = false;
    window.setTimeout(() => { label.textContent = original; }, 1800);
  }
}

A spinner only says that the interface is waiting; it does not prove that the server accepted the request. Keep useful text visible, handle failure, and preserve width where possible to avoid layout shift. For long operations, consider whether cancellation or progress is more appropriate than simply disabling the control.

Rank #4
Logitech M510 Full Size Ambidextrous 2.4 GHz Wireless Mouse
  • Your hand can relax in comfort hour after hour with this ergonomically designed mouse. Its contoured shape with soft rubber grips, gently curved sides and broad palm area give you the support you need for effortless control all day long.
  • You’ve got the control to do more, faster. Flipping through photo albums and Web pages is a breeze, especially for right-handers—with three standard buttons plus Back/Forward buttons that you can also program to switch applications, go full screen and more. And side-to-side scrolling plus zoom gives you the power to scroll horizontally and vertically through your music library, maps and Facebook feeds, and zoom in and out of photos and budget spreadsheets with a click.* * Requires Logitech SetPoint software (Windows) or Logitech Control Center software (Mac OS X)
  • Two years of battery life practically eliminates the need to replace batteries. ** The On/Off switch helps conserve power, smart sleep mode extends battery life and an indicator light eliminates surprises. ** Battery life may vary based on user and computing conditions.
  • The tiny Logitech Unifying receiver stays in your laptop. There’s no need to unplug it when you move around, so there’s less worry of it being lost. And you can easily add compatible wireless mice and keyboards to the same wireless receiver.

7. Success checkmark

Show a checkmark only after the operation really succeeds. Keep a textual status such as Saved or Uploaded; the icon and color alone are insufficient.

<button class="btn btn--status" type="button">
  <span class="btn__label">Save</span>
  <span class="btn__check" aria-hidden="true">✓</span>
</button>
.btn--status .btn__check { display: none; }
.btn--status.is-success { background: #15803d; }
.btn--status.is-success .btn__label { display: none; }
.btn--status.is-success .btn__check {
  display: inline;
  animation: check-in 180ms ease-out;
}
@keyframes check-in {
  from { opacity: 0; transform: scale(.5); }
  to { opacity: 1; transform: scale(1); }
}

For more reliable announcements, pair the button with a live status region, for example <p role="status">Saved</p>.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Toggle button with a persistent state

Favorites, mute controls, bookmarks, and show/hide controls represent an ongoing on/off state. Keep the label stable and expose the state with aria-pressed.

<button class="btn btn--toggle" type="button" aria-pressed="false">
  <span aria-hidden="true">♥</span>
  <span class="btn__label">Favorite</span>
</button>
.btn--toggle[aria-pressed="true"] {
  background: #be123c;
  transform: scale(1.04);
}
.btn--toggle[aria-pressed="true"] span:first-child {
  animation: pop 180ms ease-out;
}
@keyframes pop { 50% { transform: scale(1.3); } }
document.querySelectorAll(".btn--toggle").forEach((button) => {
  button.addEventListener("click", () => {
    const pressed = button.getAttribute("aria-pressed") === "true";
    button.setAttribute("aria-pressed", String(!pressed));
  });
});

Do not use aria-pressed for a one-time submit action. If the label changes from Mute to Unmute or Favorite to Remove favorite, that is a label-changing pattern rather than a stable toggle label.

Best Value
Sale
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.

9. Copy-to-clipboard feedback

Copying often produces no visible result, so explicit confirmation is valuable. Announce the result in a polite live region and provide a fallback when the Clipboard API is unavailable or rejected.

<div class="copy-row">
  <code id="share-url">https://example.com/article</code>
  <button class="btn btn--copy" type="button" data-copy-target="#share-url">Copy</button>
</div>
<p class="copy-status" role="status" aria-live="polite"></p>
document.querySelectorAll("[data-copy-target]").forEach((button) => {
  button.addEventListener("click", async () => {
    const target = document.querySelector(button.dataset.copyTarget);
    const status = document.querySelector(".copy-status");
    if (!target || !navigator.clipboard) {
      status.textContent = "Copy is unavailable in this browser.";
      return;
    }
    try {
      await navigator.clipboard.writeText(target.textContent.trim());
      button.textContent = "Copied";
      status.textContent = "Link copied to clipboard.";
      window.setTimeout(() => { button.textContent = "Copy"; }, 1600);
    } catch {
      status.textContent = "Copy failed. Select the text and copy it manually.";
    }
  });
});

Never announce success before the promise resolves. Clipboard access can depend on browser permissions and the page’s security context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

10. Subtle error shake

A brief shake can draw attention to an invalid action, but it must accompany a specific error message and field-level validation.

.btn--error.is-error {
  animation: shake 220ms ease-in-out;
  background: #b91c1c;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-.25rem); }
  75% { transform: translateX(.25rem); }
}
function showButtonError(button, message, statusElement) {
  button.classList.remove("is-error");
  void button.offsetWidth;
  button.classList.add("is-error");
  statusElement.textContent = message;
}

When form validation fails, focus the first invalid field rather than trapping focus on the submit button. Do not use a shake, red color, or animation as the only error signal.

Respect reduced-motion preferences

Use prefers-reduced-motion to suppress or simplify non-essential movement. Reduced motion does not necessarily require removing every color or opacity transition. W3C’s C39 technique and animation guidance distinguish non-essential interaction motion from animation that is essential to understanding or operating a feature.

@media (prefers-reduced-motion: reduce) {
  .btn--ripple::after,
  .btn__spinner,
  .btn--error.is-error,
  .btn--toggle[aria-pressed="true"] span:first-child {
    animation: none;
  }
  .btn--lift,
  .btn--press,
  .btn--arrow .btn__arrow {
    transition: none;
  }
  .btn:hover,
  .btn:active,
  .btn--arrow:hover .btn__arrow,
  .btn--arrow:focus-visible .btn__arrow {
    transform: none;
  }
}

JavaScript effects can check the preference before starting:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const motionQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
if (!motionQuery.matches) {
  // Start an optional JavaScript animation.
}
motionQuery.addEventListener("change", () => {
  document.documentElement.classList.toggle("reduce-motion", motionQuery.matches);
});

CSS remains the primary fallback. Keep animations short, non-looping, and tied to a meaningful event. Avoid constant jitter, glow, or pulse effects.

Choosing the right effect

Interaction Best use Main risk JavaScript
Hover lift Pointer feedback Useless as sole touch signal No
Focus ring Every interactive button Low contrast or removal No
Press-down Immediate activation feedback Excessive movement No
Ripple Large touch targets Pointer-only behavior Usually
Icon nudge Directional actions Meaningless decoration No
Loading Async operations No status or recovery Yes
Success check Confirmed completion False success Yes
Toggle animation Persistent state Missing aria-pressed Yes
Copy feedback Invisible utility action Clipboard failure Yes
Error shake Invalid actions No explanatory message Usually

Production checklist

  • Use a native button with the correct type.
  • Keep the accessible name meaningful and visible where practical.
  • Provide a clear :focus-visible indicator.
  • Make the control useful without hover.
  • Test Tab, Enter, Space, mouse, and touch.
  • Expose persistent toggles with aria-pressed.
  • Use text or live regions for loading, success, and failure.
  • Prevent duplicate actions when appropriate and always recover from errors.
  • Respect prefers-reduced-motion.
  • Prefer transform and opacity over layout-changing animation as a practical performance rule.
  • Test high zoom, narrow screens, dark backgrounds, contrast, and a screen reader.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

More from the Paint Desk

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.