Free ToolsGuidesCase StudiesResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/buttons

44 CSS Buttons

20 Pure CSS24 with JSPublished 2026-10-03Free · no sign-up

Every button you are likely to need, on one page: primary and secondary actions, a 3D press button, animated and glowing-border buttons, loading states, SVG stroke outlines and segmented button groups. Hand-written CSS buttons you can copy into any project: primary and secondary actions, a 3D press button, a loading state, a segmented group and a copy-to-clipboard button. Every one has visible keyboard focus, and the animated ones calm down for visitors who ask for reduced motion.

01. Gradient Glow Button

Pure CSS

A primary call-to-action with a two-stop gradient and a soft coloured glow that grows on hover. The glow is a blurred pseudo-element behind the button, so the button itself never changes size and nothing around it shifts. Keyboard focus gets the same lift as hover.

View code
<button class="ttb-glow">Start free trial</button>
.ttb-glow {
  position: relative;
  padding: 14px 28px;
  border: 0;
  border-radius: 12px;
  font: 700 16px/1 Inter, system-ui, sans-serif;
  color: #fff;
  background: linear-gradient(120deg, #7DA3FF, #5B8CFF);
  cursor: pointer;
  isolation: isolate;
  transition: transform .2s ease;
}
.ttb-glow::after {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: -1;
  border-radius: inherit;
  background: inherit;
  filter: blur(18px);
  opacity: .55;
  transition: opacity .2s ease, inset .2s ease;
}
.ttb-glow:hover,
.ttb-glow:focus-visible { transform: translateY(-2px); }
.ttb-glow:hover::after,
.ttb-glow:focus-visible::after { opacity: .9; inset: 0; }
.ttb-glow:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .ttb-glow, .ttb-glow::after { transition: none; }
}

02. Ghost Button with Sweep Fill

Pure CSS

An outline button for secondary actions. On hover a solid fill sweeps in from the left while the label switches to the dark ink colour, so the text keeps its contrast at every point of the animation. The sweep is a scaled background layer, which keeps it on the compositor and smooth on slow phones.

View code
<button class="ttb-ghost">See pricing</button>
.ttb-ghost {
  position: relative;
  overflow: hidden;
  padding: 13px 26px;
  border: 1.5px solid #7DA3FF;
  border-radius: 999px;
  background: transparent;
  color: #7DA3FF;
  font: 600 15px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  transition: color .25s ease;
}
.ttb-ghost::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #7DA3FF;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s cubic-bezier(.2,.7,.2,1);
}
.ttb-ghost:hover,
.ttb-ghost:focus-visible { color: #080A0F; }
.ttb-ghost:hover::before,
.ttb-ghost:focus-visible::before { transform: scaleX(1); }
.ttb-ghost:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

03. 3D Press Button

Pure CSS

A chunky button with a solid bottom edge that sinks when you press it, like a physical key. The depth comes from a hard box-shadow, and the active state moves the button down by exactly the shadow height, so the base stays put. Good for games, quizzes and playful sign-up flows.

View code
<button class="ttb-press">Play now</button>
.ttb-press {
  padding: 14px 30px;
  border: 0;
  border-radius: 14px;
  background: #5B8CFF;
  color: #fff;
  font: 800 16px/1 Inter, system-ui, sans-serif;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 6px 0 #2f5fd6, 0 12px 18px -6px rgba(47, 95, 214, .5);
  transform: translateY(0);
  transition: transform .08s ease, box-shadow .08s ease;
}
.ttb-press:hover { background: #6b97ff; }
.ttb-press:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 #2f5fd6, 0 4px 8px -4px rgba(47, 95, 214, .5);
}
.ttb-press:focus-visible { outline: 3px solid #080A0F; outline-offset: 4px; }

04. Button with Loading State

CSS + JS

A submit button that swaps its label for a spinner while work is in progress, then shows a confirmation. The width is locked during loading so the layout does not jump, the button is disabled to stop double submits, and aria-busy tells screen readers what is happening.

View code
<button class="ttb-load" type="button">
  <span class="ttb-load-label">Save changes</span>
  <span class="ttb-load-spin" aria-hidden="true"></span>
</button>
.ttb-load {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 160px;
  padding: 14px 24px;
  border: 0;
  border-radius: 10px;
  background: #5B8CFF;
  color: #fff;
  font: 700 15px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}
.ttb-load > * { grid-area: 1 / 1; }
.ttb-load-spin {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: ttb-spin .7s linear infinite;
}
.ttb-load[aria-busy="true"] { cursor: progress; opacity: .9; }
.ttb-load[aria-busy="true"] .ttb-load-label { opacity: 0; }
.ttb-load[aria-busy="true"] .ttb-load-spin { opacity: 1; }
.ttb-load.is-done { background: #22C55E; }
.ttb-load:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@keyframes ttb-spin { to { transform: rotate(360deg); } }
document.querySelectorAll('.ttb-load').forEach(function (btn) {
  var label = btn.querySelector('.ttb-load-label');
  btn.addEventListener('click', function () {
    if (btn.getAttribute('aria-busy') === 'true') return;
    btn.setAttribute('aria-busy', 'true');
    btn.disabled = true;
    setTimeout(function () {
      btn.removeAttribute('aria-busy');
      btn.classList.add('is-done');
      label.textContent = 'Saved';
      setTimeout(function () {
        btn.classList.remove('is-done');
        label.textContent = 'Save changes';
        btn.disabled = false;
      }, 1500);
    }, 1400);
  });
});

05. Icon Button with Sliding Arrow

Pure CSS

A text button with an inline SVG arrow that slides forward on hover. The arrow is decorative, so it carries aria-hidden and the label alone names the action. Use it for 'Read more', 'Continue' and 'Next step' links where you want a hint of motion without a loud animation.

View code
<a class="ttb-arrow" href="#">
  Continue
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg>
</a>
.ttb-arrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 22px;
  border-radius: 10px;
  background: #121722;
  border: 1px solid rgba(255, 255, 255, .14);
  color: #F5F7FA;
  font: 600 15px/1 Inter, system-ui, sans-serif;
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease;
}
.ttb-arrow svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #7DA3FF;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .25s cubic-bezier(.2,.7,.2,1);
}
.ttb-arrow:hover,
.ttb-arrow:focus-visible { border-color: #7DA3FF; background: #161c29; }
.ttb-arrow:hover svg,
.ttb-arrow:focus-visible svg { transform: translateX(4px); }
.ttb-arrow:focus-visible { outline: 2px solid #7DA3FF; outline-offset: 3px; }

06. Segmented Button Group

Pure CSS

Three buttons joined into one pill for switching views, such as Day, Week and Month. It is built on radio inputs, so only one option can be on, arrow keys move between options for free, and it works with JavaScript turned off. The selected option uses the accent fill.

View code
<fieldset class="ttb-seg">
  <legend>Range</legend>
  <label><input type="radio" name="ttb-range" checked><span>Day</span></label>
  <label><input type="radio" name="ttb-range"><span>Week</span></label>
  <label><input type="radio" name="ttb-range"><span>Month</span></label>
</fieldset>
.ttb-seg {
  display: inline-flex;
  gap: 2px;
  margin: 0;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: #0E1118;
}
.ttb-seg legend {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.ttb-seg input { position: absolute; opacity: 0; pointer-events: none; }
.ttb-seg span {
  display: block;
  padding: 9px 18px;
  border-radius: 999px;
  color: #A7AFBD;
  font: 600 14px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.ttb-seg label:hover span { color: #F5F7FA; }
.ttb-seg input:checked + span { background: #5B8CFF; color: #080A0F; }
.ttb-seg input:focus-visible + span { outline: 2px solid #7DA3FF; outline-offset: 2px; }

07. Animated Border Beam Button

Pure CSS

A dark button whose border has a moving highlight that travels around the edge. The beam is a rotating conic gradient clipped to the border with a padding-box and border-box background pair, so there are no extra elements. The animation stops for visitors who ask for reduced motion.

View code
<button class="ttb-beam">Join the beta</button>
@property --ttb-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
.ttb-beam {
  padding: 14px 28px;
  border: 2px solid transparent;
  border-radius: 12px;
  color: #F5F7FA;
  font: 700 15px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  background:
    linear-gradient(#0E1118, #0E1118) padding-box,
    conic-gradient(from var(--ttb-angle), transparent 70%, #7DA3FF 85%, #5B8CFF 92%, transparent) border-box;
  animation: ttb-beam 3s linear infinite;
}
.ttb-beam:hover {
  color: #fff;
  background:
    linear-gradient(#121722, #121722) padding-box,
    conic-gradient(from var(--ttb-angle), transparent 60%, #7DA3FF 80%, #5B8CFF 92%, transparent) border-box;
}
.ttb-beam:focus-visible { outline: 2px solid #7DA3FF; outline-offset: 3px; }
@keyframes ttb-beam { to { --ttb-angle: 360deg; } }
@media (prefers-reduced-motion: reduce) { .ttb-beam { animation: none; } }

08. Copy Button with Feedback

CSS + JS

A small button that copies text to the clipboard and confirms it with a tick and a 'Copied' label for a moment. It uses the Clipboard API, announces the result through a polite live region for screen readers, and tells the visitor to press Ctrl+C when the browser blocks clipboard access.

View code
<div class="ttb-copy">
  <code>npm install taimur-ui</code>
  <button type="button" data-copy="npm install taimur-ui">Copy</button>
  <span class="ttb-copy-sr" aria-live="polite"></span>
</div>
.ttb-copy {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  background: #0E1118;
}
.ttb-copy code { color: #D7DCE6; font: 500 14px/1 "JetBrains Mono", ui-monospace, monospace; }
.ttb-copy button {
  min-width: 82px;
  padding: 9px 14px;
  border: 0;
  border-radius: 8px;
  background: #1c2333;
  color: #F5F7FA;
  font: 600 13px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.ttb-copy button:hover { background: #26304a; }
.ttb-copy button.is-copied { background: #22C55E; color: #052e16; }
.ttb-copy button:focus-visible { outline: 2px solid #7DA3FF; outline-offset: 2px; }
.ttb-copy-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
document.querySelectorAll('.ttb-copy button').forEach(function (btn) {
  var sr = btn.parentNode.querySelector('.ttb-copy-sr');
  btn.addEventListener('click', function () {
    var text = btn.getAttribute('data-copy');
    var done = function (ok) {
      btn.textContent = ok ? '✓ Copied' : 'Press Ctrl+C';
      btn.classList.toggle('is-copied', ok);
      sr.textContent = ok ? 'Copied to clipboard' : 'Copy failed';
      setTimeout(function () { btn.textContent = 'Copy'; btn.classList.remove('is-copied'); }, 1600);
    };
    if (navigator.clipboard) navigator.clipboard.writeText(text).then(function () { done(true); }, function () { done(false); });
    else done(false);
  });
});

09. Like Button with Burst

AnimatedToggle

Pressing like fills the heart, pops it slightly larger and sends out a ring of small dots, all from CSS on the pressed state. The button is a toggle with aria-pressed and its count updates in the same text, so the state is clear without the burst.

View code
<button class="abt1" aria-pressed="false"><span class="h" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z"/></svg><i></i></span><span class="c">128</span><span class="sr"> likes</span></button>
.abt1 { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1px solid #e4e7ec; border-radius: 999px; background: #fff; color: #344054; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.abt1 .h { position: relative; display: grid; width: 24px; height: 24px; }
.abt1 svg { width: 24px; height: 24px; fill: none; stroke: #475467; stroke-width: 2; transition: transform .3s cubic-bezier(.3,1.8,.6,1); }
.abt1 i { position: absolute; inset: -6px; border-radius: 50%; background: radial-gradient(circle, #e11d48 2px, transparent 2.5px) 50% 0 / 6px 6px no-repeat, radial-gradient(circle, #f59e0b 2px, transparent 2.5px) 100% 50% / 6px 6px no-repeat, radial-gradient(circle, #e11d48 2px, transparent 2.5px) 50% 100% / 6px 6px no-repeat, radial-gradient(circle, #f59e0b 2px, transparent 2.5px) 0 50% / 6px 6px no-repeat; opacity: 0; }
.abt1[aria-pressed="true"] svg { fill: #e11d48; stroke: #e11d48; transform: scale(1.15); }
.abt1[aria-pressed="true"] i { animation: abt1 .5s ease-out; }
.abt1[aria-pressed="true"] { color: #be123c; border-color: #fecdd3; }
.abt1 .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@keyframes abt1 { 0% { opacity: 1; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.4); } }
.abt1:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .abt1 i { animation: none !important; } .abt1 svg { transition: none; } }
var b = document.querySelector('.abt1'), c = b.querySelector('.c');
b.onclick = function () { var on = b.getAttribute('aria-pressed') !== 'true'; b.setAttribute('aria-pressed', on); c.textContent = +c.textContent + (on ? 1 : -1); };

10. Send Button with Paper Plane

AnimatedFeedback

On click the paper plane flies off to the top right, the label changes to Sent, and a moment later everything returns. The flight is a keyframe on the icon only, the label change is real text, and a live region announces Message sent.

View code
<div class="abt2"><button><span class="ic" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M3 11l18-8-8 18-2-8z"/></svg></span><span class="l">Send</span></button><p class="sr" aria-live="polite"></p></div>
.abt2 button { display: inline-flex; align-items: center; gap: 10px; min-width: 120px; padding: 12px 20px; border: 0; border-radius: 12px; background: #2563eb; color: #fff; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; overflow: hidden; }
.abt2 svg { width: 20px; height: 20px; fill: #fff; }
.abt2 .ic { display: grid; }
.abt2 .go .ic { animation: abt2 .7s ease-in forwards; }
@keyframes abt2 { 30% { transform: translate(-3px, 3px); } 100% { transform: translate(60px, -40px) rotate(15deg); opacity: 0; } }
.abt2 .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.abt2 button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .abt2 .go .ic { animation: none; } }
var b = document.querySelector('.abt2 button'), l = b.querySelector('.l'), live = document.querySelector('.abt2 .sr');
b.onclick = function () { if (b.classList.contains('go')) return; b.classList.add('go'); l.textContent = 'Sent'; live.textContent = 'Message sent'; setTimeout(function () { b.classList.remove('go'); l.textContent = 'Send'; }, 1800); };

11. Follow to Following Swap

AnimatedToggle

The Follow label slides up and away as Following with a tick slides in, and turns quiet grey so the pressed state does not shout. Both labels sit in the same grid cell, so the button is always as wide as the longer one and nothing jumps when they swap.

View code
<button class="abt3" aria-pressed="false"><span class="a">Follow</span><span class="b" aria-hidden="true">✓ Following</span></button>
.abt3 { position: relative; display: inline-grid; padding: 10px 18px; border: 0; border-radius: 999px; background: #101828; color: #fff; font: 700 14px Inter, system-ui, sans-serif; cursor: pointer; transition: background .25s, color .25s; }
.abt3 span { grid-area: 1 / 1; transition: opacity .2s, transform .25s; white-space: nowrap; }
.abt3 .b { opacity: 0; transform: translateY(8px); }
.abt3[aria-pressed="true"] { background: #f2f4f7; color: #344054; }
.abt3[aria-pressed="true"] .a { opacity: 0; transform: translateY(-8px); }
.abt3[aria-pressed="true"] .b { opacity: 1; transform: none; }
.abt3:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .abt3, .abt3 span { transition: none; } }
var b = document.querySelector('.abt3');
b.onclick = function () { var on = b.getAttribute('aria-pressed') !== 'true'; b.setAttribute('aria-pressed', on); };

12. Add to Cart Fly-In

AnimatedEcommerce

A dot flies from the Add to cart button into the cart icon along a curve, then the cart count bumps. The curve comes from animating the x and y offsets on two nested elements with different easings, a classic trick for arcs without paths.

View code
<div class="abt4"><a href="#cart" class="cart" aria-label="Cart, 0 items">🛒<span class="n" aria-hidden="true">0</span></a><button>Add to cart</button></div>
.abt4 { position: relative; display: flex; flex-direction: column; align-items: center; gap: 70px; width: 240px; max-width: 100%; font-family: Inter, system-ui, sans-serif; }
.abt4 .cart { position: relative; align-self: flex-end; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: #1e293b; font-size: 20px; text-decoration: none; }
.abt4 .n { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: #22c55e; color: #052e16; font: 800 11px/18px Inter, system-ui, sans-serif; text-align: center; }
.abt4 .n.bump { animation: abt4n .4s ease; }
.abt4 button { padding: 12px 20px; border: 0; border-radius: 10px; background: #22c55e; color: #052e16; font: 800 14px Inter, system-ui, sans-serif; cursor: pointer; }
.abt4 .fx { position: absolute; left: 50%; bottom: 20px; animation: abt4x .6s ease-in forwards; }
.abt4 .fx i { display: block; width: 14px; height: 14px; border-radius: 50%; background: #22c55e; animation: abt4y .6s cubic-bezier(.2,-.6,.4,1) forwards; }
@keyframes abt4x { to { transform: translateX(95px); } }
@keyframes abt4y { to { transform: translateY(-100px) scale(.5); } }
@keyframes abt4n { 50% { transform: scale(1.4); } }
.abt4 :focus-visible { outline: 3px solid #86efac; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .abt4 .fx { display: none; } .abt4 .n.bump { animation: none; } }
var w = document.querySelector('.abt4'), n = w.querySelector('.n'), cart = w.querySelector('.cart'), k = 0;
w.querySelector('button').onclick = function () {
  var fx = document.createElement('span'); fx.className = 'fx'; fx.innerHTML = '<i></i>'; fx.setAttribute('aria-hidden', 'true'); w.appendChild(fx);
  setTimeout(function () { fx.remove(); k++; n.textContent = k; cart.setAttribute('aria-label', 'Cart, ' + k + (k === 1 ? ' item' : ' items')); n.classList.remove('bump'); void n.offsetWidth; n.classList.add('bump'); }, matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 600);
};

13. Confetti Celebration Button

AnimatedCelebration

Completing a task sprays a short burst of confetti from the button. The pieces are a dozen small spans given random directions through custom properties, removed after one second, and skipped entirely under reduced motion.

View code
<div class="abt5"><button>Mark as done</button></div>
.abt5 { position: relative; display: grid; place-items: center; width: 260px; max-width: 100%; height: 180px; overflow: hidden; }
.abt5 button { position: relative; z-index: 1; padding: 13px 22px; border: 0; border-radius: 12px; background: #7c3aed; color: #fff; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.abt5 button.done { background: #067647; }
.abt5 .cf { position: absolute; left: 50%; top: 50%; width: 8px; height: 12px; background: var(--c); animation: abt5 1s cubic-bezier(.1,.7,.3,1) forwards; }
@keyframes abt5 { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }
.abt5 button:focus-visible { outline: 3px solid #c4b5fd; outline-offset: 3px; }
var w = document.querySelector('.abt5'), b = w.querySelector('button'), cols = ['#f43f5e', '#f59e0b', '#22c55e', '#3b82f6', '#a855f7'];
b.onclick = function () {
  var done = b.classList.toggle('done'); b.textContent = done ? 'Done ✓' : 'Mark as done';
  if (!done || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
  for (var i = 0; i < 14; i++) { var s = document.createElement('span'), a = Math.random() * Math.PI * 2, d = 60 + Math.random() * 60; s.className = 'cf'; s.setAttribute('aria-hidden', 'true');
    s.style.cssText = '--c:' + cols[i % 5] + ';--x:' + Math.cos(a) * d + 'px;--y:' + Math.sin(a) * d + 'px;--r:' + (Math.random() * 720 - 360) + 'deg';
    w.appendChild(s); setTimeout(s.remove.bind(s), 1000); }
};

14. Press and Hold to Confirm

AnimatedDestructive

A destructive button that only fires after being held for a second and a half, with a fill showing progress. It works with the pointer and with Space or Enter held on the keyboard, and releasing early cancels. The instruction is in the button's description.

View code
<div class="abt6"><button aria-describedby="abt6h"><span class="f" aria-hidden="true"></span><span class="l">Hold to delete</span></button><p id="abt6h">Press and hold for 1.5 seconds.</p></div>
.abt6 { display: grid; justify-items: center; gap: 8px; font-family: Inter, system-ui, sans-serif; }
.abt6 button { position: relative; overflow: hidden; isolation: isolate; width: 200px; max-width: 100%; padding: 13px; border: 1px solid #f87171; border-radius: 10px; background: #1f1215; color: #fecaca; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; user-select: none; }
.abt6 .f { position: absolute; inset: 0; z-index: -1; background: #b91c1c; transform: scaleX(0); transform-origin: left; }
.abt6 button.hold .f { transform: scaleX(1); transition: transform 1.5s linear; }
.abt6 button.ok { background: #b91c1c; color: #fff; }
.abt6 p { margin: 0; color: #94a3b8; font-size: 12px; }
.abt6 button:focus-visible { outline: 2px solid #fca5a5; outline-offset: 3px; }
var b = document.querySelector('.abt6 button'), l = b.querySelector('.l'), t;
function start(e) { if (e.type === 'keydown' && (e.repeat || (e.key !== ' ' && e.key !== 'Enter'))) return; if (e.type === 'keydown') e.preventDefault(); if (b.classList.contains('ok')) return; b.classList.add('hold'); t = setTimeout(function () { b.classList.remove('hold'); b.classList.add('ok'); l.textContent = 'Deleted'; }, 1500); }
function stop() { clearTimeout(t); b.classList.remove('hold'); }
b.addEventListener('pointerdown', start); b.addEventListener('keydown', start);
['pointerup', 'pointerleave', 'keyup', 'blur'].forEach(function (ev) { b.addEventListener(ev, stop); });
b.addEventListener('click', function (e) { e.preventDefault(); });

15. Subscribe with Ringing Bell

AnimatedToggle

Subscribing turns the button solid and gives its bell a short ring, a satisfying confirmation borrowed from video platforms. The ring plays once when the pressed state becomes true and never loops.

View code
<button class="abt7" aria-pressed="false"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 16V11a6 6 0 1 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0"/></svg><span>Subscribe</span></button>
.abt7 { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border: 1px solid #d0d5dd; border-radius: 999px; background: #fff; color: #101828; font: 700 14px Inter, system-ui, sans-serif; cursor: pointer; transition: background .2s, color .2s; }
.abt7 svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; transform-origin: 50% 10%; }
.abt7[aria-pressed="true"] { background: #101828; color: #fff; border-color: #101828; }
.abt7[aria-pressed="true"] svg { fill: currentColor; animation: abt7 .8s ease; }
@keyframes abt7 { 15% { transform: rotate(18deg); } 30% { transform: rotate(-16deg); } 45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(2deg); } }
.abt7:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .abt7 svg { animation: none !important; } }
var b = document.querySelector('.abt7'), s = b.querySelector('span');
b.onclick = function () { var on = b.getAttribute('aria-pressed') !== 'true'; b.setAttribute('aria-pressed', on); s.textContent = on ? 'Subscribed' : 'Subscribe'; };

16. Rotating Conic Glow Border

GlowAnimation

A conic gradient spins behind the button and only a 2px ring of it shows, with a blurred copy underneath for the glow. The angle is a registered @property so the browser can animate it; browsers without @property show the ring standing still.

View code
<button class="gbb1"><span>Launch project</span></button>
@property --gbb1a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.gbb1 { position: relative; padding: 2px; border: 0; border-radius: 14px; background: conic-gradient(from var(--gbb1a), #22d3ee, #a855f7, #f43f5e, #22d3ee); cursor: pointer; animation: gbb1 4s linear infinite; }
.gbb1::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: inherit; filter: blur(12px); opacity: .7; z-index: -1; }
.gbb1 span { display: block; padding: 14px 26px; border-radius: 12px; background: #0e1118; color: #fff; font: 700 16px Inter, system-ui, sans-serif; }
@keyframes gbb1 { to { --gbb1a: 360deg; } }
.gbb1:focus-visible { outline: 2px solid #fff; outline-offset: 6px; }
@media (prefers-reduced-motion: reduce) { .gbb1 { animation: none; } }

17. Glow on Hover Only

GlowHover

At rest this is a plain outlined button. On hover and focus the border turns cyan and stacked box-shadows, one tight, one wide and one inset, create a neon glow. Animating box-shadow is acceptable here because the transition is short and only runs on interaction.

View code
<button class="gbb2">Connect wallet</button>
.gbb2 { padding: 14px 26px; border: 1px solid #2f3a5c; border-radius: 10px; background: #111627; color: #cfd8ff; font: 600 16px Inter, system-ui, sans-serif; cursor: pointer; transition: border-color .25s, box-shadow .25s, color .25s; }
.gbb2:hover, .gbb2:focus-visible { border-color: #22d3ee; color: #fff; box-shadow: 0 0 0 1px #22d3ee, 0 0 18px rgba(34,211,238,.55), inset 0 0 12px rgba(34,211,238,.15); outline: none; }

18. Pulsing Glow Ring

GlowAttention

A ring of glow expands from the button and fades every two seconds, to draw the eye to a single action such as Go live. The ring is an animated box-shadow on a pseudo-element. Use it sparingly, and never on more than one button in view.

View code
<button class="gbb3"><span class="dot" aria-hidden="true"></span>Go live</button>
.gbb3 { position: relative; display: inline-flex; align-items: center; gap: 10px; padding: 14px 26px; border: 0; border-radius: 999px; background: #dc2626; color: #fff; font: 800 16px Inter, system-ui, sans-serif; cursor: pointer; }
.gbb3::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(248,113,113,.7); animation: gbb3 2s ease-out infinite; }
.gbb3 .dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; }
@keyframes gbb3 { to { box-shadow: 0 0 0 16px rgba(248,113,113,0); } }
.gbb3:focus-visible { outline: 3px solid #fecaca; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .gbb3::after { animation: none; } }

19. Light Beam Around the Edge

GlowAnimation

A narrow beam of light travels around the border: a conic gradient with one bright slice, masked so only a 1.5px ring is visible. The mask is two layers combined with exclude, which cuts the inside out and leaves the button background untouched.

View code
<button class="gbb4">Upgrade to Pro</button>
@property --gbb4a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.gbb4 { position: relative; padding: 15px 28px; border: 0; border-radius: 12px; background: #0f1322; color: #e9e7ff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; }
.gbb4::before { content: ""; position: absolute; inset: 0; padding: 1.5px; border-radius: inherit; background: conic-gradient(from var(--gbb4a), transparent 0 75%, #c4b5fd 88%, #fff 92%, transparent 96%), #2c2f4d; -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); animation: gbb4 3s linear infinite; pointer-events: none; }
@keyframes gbb4 { to { --gbb4a: 360deg; } }
.gbb4:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .gbb4::before { animation: none; } }

20. Soft Coloured Glow

GlowShadow

On a light page a neon glow looks out of place, so this one uses a coloured, blurred shadow under the button instead. The shadow is the button colour at low opacity and grows slightly on hover, which reads as glow and lift together.

View code
<button class="gbb5">Subscribe</button>
.gbb5 { padding: 15px 32px; border: 0; border-radius: 12px; background: #7c3aed; color: #fff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; box-shadow: 0 10px 24px -8px rgba(124,58,237,.6); transition: box-shadow .25s, transform .25s; }
.gbb5:hover, .gbb5:focus-visible { transform: translateY(-2px); box-shadow: 0 16px 32px -8px rgba(124,58,237,.75); }
.gbb5:focus-visible { outline: 3px solid #c4b5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .gbb5 { transition: none; } .gbb5:hover, .gbb5:focus-visible { transform: none; } }

21. Glow That Follows the Cursor

GlowJavaScript

A radial highlight on the border follows the pointer. A few lines of script write the pointer position into two custom properties, and the border is a masked radial gradient centred on them. Without JavaScript the button simply has a plain border.

View code
<button class="gbb6">Try the playground</button>
.gbb6 { --x: 50%; --y: 50%; position: relative; padding: 16px 30px; border: 0; border-radius: 14px; background: #121726; color: #f1f5ff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; }
.gbb6::before { content: ""; position: absolute; inset: 0; padding: 1.5px; border-radius: inherit; background: radial-gradient(120px circle at var(--x) var(--y), #38bdf8, transparent 70%), #2a324d; -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); pointer-events: none; }
.gbb6:focus-visible { outline: 2px solid #38bdf8; outline-offset: 4px; }
var b = document.querySelector('.gbb6');
b.addEventListener('pointermove', function (e) {
  var r = b.getBoundingClientRect();
  b.style.setProperty('--x', (e.clientX - r.left) + 'px');
  b.style.setProperty('--y', (e.clientY - r.top) + 'px');
});

22. Glowing Selected Option

GlowGroup

Glow as a selection state: three billing buttons in a group, and the one with aria-pressed set to true glows. Clicking moves the glow, and the pressed state is announced, so the highlight is never the only cue.

View code
<div class="gbb7" role="group" aria-label="Billing period"><button aria-pressed="false">Monthly</button><button aria-pressed="true">Yearly</button><button aria-pressed="false">Lifetime</button></div>
.gbb7 { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; box-sizing: border-box; max-width: 100%; }
.gbb7 button { padding: 12px 18px; border: 1px solid #2c3554; border-radius: 10px; background: #121828; color: #aab4d4; font: 600 15px Inter, system-ui, sans-serif; cursor: pointer; transition: box-shadow .25s, border-color .25s, color .25s; }
.gbb7 [aria-pressed="true"] { border-color: #a78bfa; color: #fff; box-shadow: 0 0 0 1px #a78bfa, 0 0 22px rgba(167,139,250,.45); }
.gbb7 button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
document.querySelectorAll('.gbb7 button').forEach(function (b, _, all) {
  b.addEventListener('click', function () { all.forEach(function (x) { x.setAttribute('aria-pressed', x === b ? 'true' : 'false'); }); });
});

23. Button with Inline Spinner

LoadingSpinner

Clicking shows a spinner, changes the label to Saving and sets aria-busy and aria-disabled. A minimum width stops the button from jumping as the label changes. After a pretend two-second request it returns to normal.

View code
<button class="lb1"><span class="sp" aria-hidden="true"></span><span class="t">Save changes</span></button>
.lb1 { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 170px; padding: 13px 22px; border: 0; border-radius: 10px; background: #2563eb; color: #fff; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.lb1 .sp { display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: lb1 .7s linear infinite; }
.lb1[aria-busy="true"] { background: #3b6fe0; cursor: progress; }
.lb1[aria-busy="true"] .sp { display: block; }
@keyframes lb1 { to { transform: rotate(360deg); } }
.lb1:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .lb1 .sp { animation-duration: 2s; } }
var b = document.querySelector('.lb1'), t = b.querySelector('.t');
b.addEventListener('click', function () {
  if (b.getAttribute('aria-busy') === 'true') return;
  b.setAttribute('aria-busy', 'true'); b.setAttribute('aria-disabled', 'true'); t.textContent = 'Saving…';
  setTimeout(function () { b.removeAttribute('aria-busy'); b.removeAttribute('aria-disabled'); t.textContent = 'Save changes'; }, 2000);
});

24. Button That Fills as Progress

LoadingProgress

The button background fills from left to right like a progress bar while an upload runs, then turns green with Done. The percentage is in the label so it can be read, and the label is a polite live region so the finish is announced.

View code
<button class="lb2"><span class="fill" aria-hidden="true"></span><span class="t" aria-live="polite">Upload file</span></button>
.lb2 { box-sizing: border-box; --p: 0%; position: relative; overflow: hidden; width: 200px; max-width: 100%; padding: 14px 0; border: 1px solid #3b4a7a; border-radius: 10px; background: #141a2e; color: #e6ebff; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.lb2 .fill { position: absolute; inset: 0; width: var(--p); background: #4f46e5; transition: width .2s linear; }
.lb2 .t { position: relative; }
.lb2.done { border-color: #16a34a; }
.lb2.done .fill { background: #15803d; }
.lb2:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 3px; }
var b = document.querySelector('.lb2'), t = b.querySelector('.t');
b.addEventListener('click', function () {
  if (b.dataset.run) return;
  b.dataset.run = 1; b.classList.remove('done');
  var p = 0, id = setInterval(function () {
    p += 10; b.style.setProperty('--p', p + '%'); t.textContent = 'Uploading ' + p + '%';
    if (p >= 100) { clearInterval(id); b.classList.add('done'); t.textContent = 'Done ✓'; delete b.dataset.run; }
  }, 180);
});

25. Three Dots Loading State

LoadingDots

The label is swapped for three bouncing dots while waiting, and a visually hidden Sending message keeps the button's name meaningful for screen readers. The fixed width means the layout does not jump when the label disappears.

View code
<button class="lb3"><span class="t">Send message</span><span class="d" aria-hidden="true"><i></i><i></i><i></i></span><span class="sr">Sending</span></button>
.lb3 { position: relative; width: 180px; max-width: 100%; height: 50px; border: 0; border-radius: 999px; background: #111827; color: #fff; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.lb3 .d, .lb3 .sr { display: none; }
.lb3 .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lb3.busy .t { display: none; }
.lb3.busy .d { display: inline-flex; gap: 6px; }
.lb3.busy .sr { display: block; }
.lb3 i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: lb3 1s ease-in-out infinite; }
.lb3 i:nth-child(2) { animation-delay: .15s; } .lb3 i:nth-child(3) { animation-delay: .3s; }
@keyframes lb3 { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-6px); opacity: 1; } }
.lb3:focus-visible { outline: 3px solid #9ca3af; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .lb3 i { animation: none; } }
var b = document.querySelector('.lb3');
b.addEventListener('click', function () {
  if (b.classList.contains('busy')) return;
  b.classList.add('busy'); b.setAttribute('aria-disabled', 'true');
  setTimeout(function () { b.classList.remove('busy'); b.removeAttribute('aria-disabled'); }, 2200);
});

26. Loading to Success Morph

LoadingSuccess

A wide button shrinks into a circle with a spinner, then shows a tick and expands again. Width and border-radius transition together, which works because the button has an explicit width in each state. The result is announced through a live region below.

View code
<div class="lb4"><button type="button"><span class="t">Pay $24.00</span></button><p class="msg" aria-live="polite"></p></div>
.lb4 { display: grid; justify-items: center; gap: 10px; font: 700 15px Inter, system-ui, sans-serif; }
.lb4 button { width: 200px; max-width: 100%; height: 52px; border: 0; border-radius: 12px; background: #15803d; color: #fff; font: inherit; cursor: pointer; transition: width .35s ease, border-radius .35s ease; }
.lb4 button.busy, .lb4 button.ok { width: 52px; border-radius: 26px; }
.lb4 button.busy .t, .lb4 button.ok .t { display: none; }
.lb4 button.busy::after { content: ""; display: block; width: 20px; height: 20px; margin: auto; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: lb4 .7s linear infinite; }
.lb4 button.ok::after { content: "✓"; font-size: 22px; }
.lb4 .msg { margin: 0; min-height: 1.2em; color: #86efac; font-weight: 600; font-size: 14px; }
@keyframes lb4 { to { transform: rotate(360deg); } }
.lb4 button:focus-visible { outline: 3px solid #86efac; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .lb4 button { transition: none; } }
var b = document.querySelector('.lb4 button'), m = document.querySelector('.lb4 .msg');
b.addEventListener('click', function () {
  if (b.className) return;
  b.className = 'busy'; b.setAttribute('aria-label', 'Processing payment'); m.textContent = '';
  setTimeout(function () { b.className = 'ok'; b.setAttribute('aria-label', 'Payment complete'); m.textContent = 'Payment complete'; }, 1600);
  setTimeout(function () { b.className = ''; b.removeAttribute('aria-label'); m.textContent = ''; }, 3600);
});

27. Shimmer While Waiting

LoadingShimmer

While busy, a light shimmer sweeps across the button, a calm alternative to a spinner for short waits. Your fetch code only has to toggle one class and the disabled property, and the label changes to say what is happening. Focus returns to the button when it is done.

View code
<button class="lb5">Refresh data</button>
.lb5 { position: relative; overflow: hidden; padding: 14px 26px; border: 1px solid #d0d5dd; border-radius: 10px; background: #fff; color: #1d2939; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.lb5.is-loading { color: #475467; cursor: progress; }
.lb5.is-loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(37,99,235,.18), transparent); transform: translateX(-100%); animation: lb5 1.1s ease-in-out infinite; }
@keyframes lb5 { to { transform: translateX(100%); } }
.lb5:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .lb5.is-loading::after { animation-duration: 3s; } }
var b = document.querySelector('.lb5');
b.addEventListener('click', function () {
  b.classList.add('is-loading'); b.disabled = true; b.textContent = 'Refreshing…';
  setTimeout(function () { b.classList.remove('is-loading'); b.disabled = false; b.textContent = 'Refresh data'; b.focus(); }, 2000);
});

28. Progress Ring Icon Button

LoadingIcon

A round download button whose border becomes a progress ring drawn with a conic gradient, so no SVG ring is needed. The fill comes from a custom property, and the aria-label is updated with the progress so the state is available to screen readers as well as shown.

View code
<button class="lb6" aria-label="Download report"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v11M7 10l5 5 5-5M5 20h14"/></svg></button>
.lb6 { --p: 0; position: relative; display: grid; place-items: center; width: 64px; height: 64px; border: 0; border-radius: 50%; background: conic-gradient(#38bdf8 calc(var(--p) * 1%), #26304e 0); cursor: pointer; }
.lb6::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #10162a; }
.lb6 svg { position: relative; width: 26px; height: 26px; fill: none; stroke: #e0f2fe; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb6:focus-visible { outline: 2px solid #38bdf8; outline-offset: 4px; }
var b = document.querySelector('.lb6');
b.addEventListener('click', function () {
  if (b.dataset.run) return;
  b.dataset.run = 1;
  var p = 0, id = setInterval(function () {
    p += 5; b.style.setProperty('--p', p);
    b.setAttribute('aria-label', 'Downloading, ' + p + ' percent');
    if (p >= 100) { clearInterval(id); b.setAttribute('aria-label', 'Download complete'); delete b.dataset.run; }
  }, 90);
});

29. Busy Button That Blocks Double Submits

LoadingForms

A real form whose submit button turns busy on submit and ignores further clicks, which prevents double orders. It uses aria-disabled rather than disabled, so the button stays focusable and keyboard users do not lose their place.

View code
<form class="lb7"><label for="lb7e">Email</label><input id="lb7e" type="email" value="ana@example.com" required><button type="submit">Request invite</button><p aria-live="polite"></p></form>
.lb7 { display: grid; gap: 8px; width: 280px; max-width: 100%; box-sizing: border-box; font: 15px Inter, system-ui, sans-serif; color: #1d2939; }
.lb7 label { font-weight: 600; font-size: 14px; }
.lb7 input { min-width: 0; padding: 11px 12px; border: 1px solid #98a2b3; border-radius: 8px; font: inherit; }
.lb7 button { margin-top: 4px; padding: 12px; border: 0; border-radius: 8px; background: #0f766e; color: #fff; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.lb7 button[aria-disabled="true"] { background: #4b8f8a; cursor: progress; }
.lb7 p { margin: 0; min-height: 1.3em; font-size: 14px; color: #0f766e; }
.lb7 :focus-visible { outline: 3px solid #5eead4; outline-offset: 2px; }
var f = document.querySelector('.lb7'), b = f.querySelector('button'), out = f.querySelector('p');
f.addEventListener('submit', function (e) {
  e.preventDefault();
  if (b.getAttribute('aria-disabled') === 'true') return;
  b.setAttribute('aria-disabled', 'true'); b.textContent = 'Sending…'; out.textContent = '';
  setTimeout(function () { b.removeAttribute('aria-disabled'); b.textContent = 'Request invite'; out.textContent = 'Invite requested. Check your inbox.'; }, 1800);
});

30. Border That Draws Itself

SVGHover

An SVG rectangle sits over the button and its stroke is hidden with stroke-dasharray and stroke-dashoffset. On hover or keyboard focus the offset animates to zero, so the outline draws around the button in one continuous line. pathLength="100" keeps the dash maths simple at any size.

View code
<button class="ssb1"><svg viewBox="0 0 200 56" aria-hidden="true"><rect x="1" y="1" width="198" height="54" rx="10" pathLength="100"/></svg>Get started</button>
.ssb1 { box-sizing: border-box; position: relative; width: 200px; max-width: 100%; height: 56px; border: 1px solid #2a3350; border-radius: 10px; background: #121828; color: #e8ecff; font: 600 16px Inter, system-ui, sans-serif; cursor: pointer; }
.ssb1 svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ssb1 rect { fill: none; stroke: #7c9cff; stroke-width: 2; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .7s ease; }
.ssb1:hover rect, .ssb1:focus-visible rect { stroke-dashoffset: 0; }
.ssb1:focus-visible { outline: 2px solid #7c9cff; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .ssb1 rect { transition: none; } }

31. Chasing Stroke Segment

SVGAnimation

A short bright dash travels round the border on a loop, made by a dash pattern of 18 visible units and 82 gaps whose offset is animated. It suits one important call to action. The animation stops for visitors who prefer reduced motion, leaving a static highlight.

View code
<button class="ssb2"><svg viewBox="0 0 220 56" aria-hidden="true"><rect class="base" x="1" y="1" width="218" height="54" rx="27"/><rect class="run" x="1" y="1" width="218" height="54" rx="27" pathLength="100"/></svg>Join the beta</button>
.ssb2 { position: relative; width: 220px; max-width: 100%; height: 56px; border: 0; border-radius: 28px; background: #0f1424; color: #f2f4ff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; }
.ssb2 svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ssb2 rect { fill: none; stroke-width: 2; }
.ssb2 .base { stroke: #2b3354; }
.ssb2 .run { stroke: #22d3ee; stroke-linecap: round; stroke-dasharray: 18 82; animation: ssb2 2.4s linear infinite; filter: drop-shadow(0 0 4px #22d3ee); }
@keyframes ssb2 { to { stroke-dashoffset: -100; } }
.ssb2:focus-visible { outline: 2px solid #22d3ee; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .ssb2 .run { animation: none; } }

32. Corner Brackets to Full Frame

SVGHover

At rest only the four corners of the frame show, like camera brackets. The stroke-dasharray is a list of nine values worked out from the real side lengths so each dash sits on a corner. On hover every dash grows and every gap shrinks to zero, closing the frame evenly from all four corners.

View code
<button class="ssb3"><svg viewBox="0 0 200 60" aria-hidden="true"><rect x="1" y="1" width="198" height="58"/></svg>View portfolio</button>
.ssb3 { position: relative; width: 200px; max-width: 100%; height: 60px; border: 0; background: transparent; color: #111827; font: 700 15px Inter, system-ui, sans-serif; letter-spacing: .02em; cursor: pointer; }
.ssb3 svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
/* perimeter 512: top 198, right 58, bottom 198, left 58; 12px arms at each corner */
.ssb3 rect { fill: none; stroke: #111827; stroke-width: 2.5; stroke-dasharray: 12 174 24 34 24 174 24 34 12 0; transition: stroke-dasharray .5s ease; }
.ssb3:hover rect, .ssb3:focus-visible rect { stroke-dasharray: 99 0 128 0 128 0 128 0 29 0; }
.ssb3:focus-visible { outline: 2px dashed #2563eb; outline-offset: 6px; }
@media (prefers-reduced-motion: reduce) { .ssb3 rect { transition: none; } }

33. Icon That Draws on Hover

SVGIcon

A solid button whose arrow icon is redrawn line by line when the pointer arrives: the shaft first, then the head after a short delay. The label is the accessible name and the icon is aria-hidden, so screen readers hear only Continue.

View code
<button class="ssb4">Continue <svg viewBox="0 0 24 24" aria-hidden="true"><path class="shaft" d="M4 12h15" pathLength="1"/><path class="head" d="M13 6l6 6-6 6" pathLength="1"/></svg></button>
.ssb4 { display: inline-flex; align-items: center; gap: 10px; padding: 14px 22px; border: 0; border-radius: 12px; background: #4f46e5; color: #fff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; }
.ssb4 svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ssb4 path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.ssb4:hover path, .ssb4:focus-visible path { animation: ssb4 .45s ease both; }
.ssb4:hover .head, .ssb4:focus-visible .head { animation-delay: .2s; }
@keyframes ssb4 { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.ssb4:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ssb4 path { animation: none !important; } }

34. Save Button with Drawn Tick

SVGState

Clicking toggles aria-pressed, and the pressed state swaps the label to Saved while a tick is drawn inside a filled circle. The state lives on the button itself, so assistive technology announces it as a toggle button that is pressed or not pressed.

View code
<button class="ssb5" aria-pressed="false"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M7 12.5l3.2 3.2L17 9" pathLength="1"/></svg><span class="off">Save design</span><span class="on">Saved</span></button>
.ssb5 { display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px 12px 14px; border: 1px solid #334066; border-radius: 999px; background: #151b2e; color: #e8ecff; font: 600 15px Inter, system-ui, sans-serif; cursor: pointer; }
.ssb5 svg { width: 24px; height: 24px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ssb5 circle { stroke: #475384; transition: stroke .3s, fill .3s; }
.ssb5 path { stroke: #0e1118; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .4s ease .1s; }
.ssb5 .on { display: none; }
.ssb5[aria-pressed="true"] { border-color: #34d399; }
.ssb5[aria-pressed="true"] circle { stroke: #34d399; fill: #34d399; }
.ssb5[aria-pressed="true"] path { stroke-dashoffset: 0; }
.ssb5[aria-pressed="true"] .on { display: inline; }
.ssb5[aria-pressed="true"] .off { display: none; }
.ssb5:focus-visible { outline: 2px solid #34d399; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ssb5 * { transition: none !important; } }
document.querySelector('.ssb5').addEventListener('click', function () {
  this.setAttribute('aria-pressed', this.getAttribute('aria-pressed') === 'true' ? 'false' : 'true');
});

35. Gradient Stroke with Glow

SVGGradient

The outline is an SVG stroke painted with a linearGradient, which a CSS border cannot do on a rounded shape without extra layers. A drop-shadow filter adds a soft glow that brightens on hover, and the label stays plain white for contrast.

View code
<button class="ssb6"><svg viewBox="0 0 210 56" aria-hidden="true"><defs><linearGradient id="ssb6g" x1="0" x2="1"><stop offset="0" stop-color="#f472b6"/><stop offset=".5" stop-color="#a78bfa"/><stop offset="1" stop-color="#22d3ee"/></linearGradient></defs><rect x="1.5" y="1.5" width="207" height="53" rx="14"/></svg>Explore themes</button>
.ssb6 { position: relative; width: 210px; max-width: 100%; height: 56px; border: 0; border-radius: 14px; background: #10131f; color: #fff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; }
.ssb6 svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ssb6 rect { fill: none; stroke: url(#ssb6g); stroke-width: 3; filter: drop-shadow(0 0 3px rgba(167,139,250,.5)); transition: filter .3s; }
.ssb6:hover rect, .ssb6:focus-visible rect { filter: drop-shadow(0 0 9px rgba(167,139,250,.9)); }
.ssb6:focus-visible { outline: 2px solid #fff; outline-offset: 5px; }

36. Text Link with Wavy Underline

SVGLink

A text link whose underline is a hand-drawn wave in an inline SVG, drawn from left to right on hover and focus with stroke-dashoffset. Because it is a real link it keeps link semantics, and the wave stretches with the text because preserveAspectRatio is none.

View code
<a class="ssb7" href="#pricing">See pricing<svg viewBox="0 0 120 10" preserveAspectRatio="none" aria-hidden="true"><path d="M1 5 Q 8 0 15 5 T 29 5 T 43 5 T 57 5 T 71 5 T 85 5 T 99 5 T 113 5 T 119 5" pathLength="1"/></svg></a>
.ssb7 { position: relative; display: inline-block; padding-bottom: 10px; color: #0f172a; font: 800 22px Inter, system-ui, sans-serif; text-decoration: none; }
.ssb7 svg { position: absolute; left: 0; bottom: 0; width: 100%; height: 10px; overflow: visible; }
.ssb7 path { fill: none; stroke: #e11d48; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .6s ease; vector-effect: non-scaling-stroke; }
.ssb7:hover path, .ssb7:focus-visible path { stroke-dashoffset: 0; }
.ssb7:focus-visible { outline: 2px solid #e11d48; outline-offset: 4px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .ssb7 path { transition: none; } }

37. Attached Button Group

ToolbarGroup

Three buttons joined into one control, with shared borders and rounded outer corners only. The group is a role="group" with a label, so screen readers announce its purpose, and adjacent borders collapse with a negative margin.

View code
<div class="bgr" role="group" aria-label="Text alignment">
  <button aria-pressed="true">Left</button><button aria-pressed="false">Center</button><button aria-pressed="false">Right</button>
</div>
.bgr { box-sizing: border-box; max-width: 100%; display: inline-flex; font: 600 14px Inter, system-ui, sans-serif; }
.bgr button { padding: 9px 16px; border: 1.5px solid #d0d5dd; background: #fff; color: #344054; font: inherit; cursor: pointer; }
.bgr button + button { margin-left: -1.5px; }
.bgr button:first-child { border-radius: 10px 0 0 10px; }
.bgr button:last-child { border-radius: 0 10px 10px 0; }
.bgr button[aria-pressed=true] { position: relative; border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
.bgr button:focus-visible { position: relative; z-index: 1; outline: 2px solid #2563eb; outline-offset: 1px; }
const bs = document.querySelectorAll('.bgr button');
bs.forEach(b => b.addEventListener('click', () => bs.forEach(x => x.setAttribute('aria-pressed', String(x === b)))));

38. Icon Toolbar Group

IconToolbar

An editor toolbar made of icon buttons in a pill, using role="toolbar" with arrow-key navigation so the group is one Tab stop. Each icon button has an aria-label, and toggle buttons such as Bold report their state with aria-pressed.

View code
<div class="tbr" role="toolbar" aria-label="Formatting">
  <button aria-label="Bold" aria-pressed="true"><b>B</b></button>
  <button aria-label="Italic" aria-pressed="false" tabindex="-1"><i>I</i></button>
  <button aria-label="Underline" aria-pressed="false" tabindex="-1"><u>U</u></button>
  <button aria-label="Insert link" tabindex="-1">&#128279;</button>
</div>
.tbr { box-sizing: border-box; max-width: 100%; display: inline-flex; gap: 2px; padding: 4px; border: 1px solid #2c3346; border-radius: 12px; background: #151a26; }
.tbr button { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: #e7ebf5; font: 16px Georgia, serif; cursor: pointer; }
.tbr button:hover { background: #1e2433; }
.tbr button[aria-pressed=true] { background: #2b3a6b; color: #fff; }
.tbr button:focus-visible { outline: 2px solid #9db8ff; outline-offset: -2px; }
const tb = [...document.querySelectorAll('.tbr button')];
tb.forEach((b, i) => {
  b.addEventListener('click', () => { if (b.hasAttribute('aria-pressed')) b.setAttribute('aria-pressed', String(b.getAttribute('aria-pressed') !== 'true')); });
  b.addEventListener('keydown', e => {
    const d = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0; if (!d) return;
    const n = tb[(i + d + tb.length) % tb.length]; tb.forEach(x => x.tabIndex = -1); n.tabIndex = 0; n.focus();
  });
});

39. Segmented Toggle Buttons

ToggleFilter

A rounded segmented control for switching a view between Day, Week and Month. It is built from buttons with aria-pressed rather than radios, which suits toolbars where the change happens straight away, and the active segment is raised.

View code
<div class="sgb" role="group" aria-label="Range">
  <button aria-pressed="false">Day</button><button aria-pressed="true">Week</button><button aria-pressed="false">Month</button>
</div>
.sgb { box-sizing: border-box; max-width: 100%; display: inline-flex; padding: 4px; border-radius: 12px; background: #eef0f4; font: 600 14px Inter, system-ui, sans-serif; }
.sgb button { padding: 8px 18px; border: 0; border-radius: 9px; background: none; color: #475467; font: inherit; cursor: pointer; }
.sgb button[aria-pressed=true] { background: #fff; color: #101828; box-shadow: 0 1px 3px rgba(16,24,40,.18); }
.sgb button:focus-visible { outline: 2px solid #2563eb; }
const sg = document.querySelectorAll('.sgb button');
sg.forEach(b => b.addEventListener('click', () => sg.forEach(x => x.setAttribute('aria-pressed', String(x === b)))));

40. Primary and Secondary Pair

ActionsForm

The common footer pair of a quiet Cancel and a bold Save, aligned to the right. The primary action comes last in reading order to match most platforms, and both buttons have equal height so the pair looks balanced.

View code
<div class="pair"><button class="ghost">Cancel</button><button class="main">Save changes</button></div>
.pair { box-sizing: border-box; max-width: 100%; width: 360px; display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid #262d3e; font: 700 14px Inter, system-ui, sans-serif; }
.pair button { padding: 10px 16px; border-radius: 10px; font: inherit; cursor: pointer; }
.ghost { border: 1px solid #343c51; background: none; color: #e7ebf5; }
.main { border: 0; background: #7c9cff; color: #0e1118; }
.pair button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

41. Pagination Button Group

PaginationNavigation

Page number buttons in an attached group with Previous and Next at the ends. It is a nav landmark labelled Pagination, the current page is marked with aria-current, and Previous is disabled on the first page.

View code
<nav class="pgn" aria-label="Pagination">
  <a aria-disabled="true">Previous</a><a href="#" aria-current="page">1</a><a href="#">2</a><a href="#">3</a><a href="#">Next</a>
</nav>
.pgn { box-sizing: border-box; max-width: 100%; display: inline-flex; flex-wrap: wrap; font: 600 14px Inter, system-ui, sans-serif; }
.pgn a { padding: 8px 13px; border: 1.5px solid #d0d5dd; color: #344054; text-decoration: none; }
.pgn a + a { margin-left: -1.5px; }
.pgn a:first-child { border-radius: 10px 0 0 10px; }
.pgn a:last-child { border-radius: 0 10px 10px 0; }
.pgn a:hover { background: #f9fafb; }
.pgn a[aria-current] { position: relative; border-color: #101828; background: #101828; color: #fff; }
.pgn a[aria-disabled] { color: #98a2b3; }
.pgn a:focus-visible { position: relative; z-index: 1; outline: 2px solid #2563eb; }

42. Vertical Button Stack

StackSidebar

A vertical group of actions for sidebars and side panels, with full-width buttons that share borders. A destructive action at the bottom is separated by a gap and coloured red, so it is not pressed by accident.

View code
<div class="vs" role="group" aria-label="File actions">
  <button>Rename</button><button>Duplicate</button><button>Move to folder</button>
  <button class="del">Delete file</button>
</div>
.vs { box-sizing: border-box; max-width: 100%; width: 220px; display: flex; flex-direction: column; font: 500 14px Inter, system-ui, sans-serif; }
.vs button { padding: 10px 14px; border: 1px solid #2c3346; background: #151a26; color: #e7ebf5; font: inherit; text-align: left; cursor: pointer; }
.vs button + button { margin-top: -1px; }
.vs button:first-child { border-radius: 10px 10px 0 0; }
.vs button:nth-child(3) { border-radius: 0 0 10px 10px; }
.vs .del { margin-top: 10px !important; border-radius: 10px; border-color: #7f1d1d; color: #fca5a5; }
.vs button:hover { background: #1e2433; }
.vs button:focus-visible { position: relative; outline: 2px solid #9db8ff; }

43. Filter Chip Group

FilterToggle

A wrapping group of toggle chips for quick filters, where several can be on at once. Each chip is a button with aria-pressed, a tick appears on active chips, and a Clear button resets them all in one click.

View code
<div class="fcg" role="group" aria-label="Filters">
  <button aria-pressed="true">In stock</button><button aria-pressed="false">On sale</button><button aria-pressed="true">Free shipping</button><button aria-pressed="false">New</button>
  <button class="clr">Clear</button>
</div>
.fcg { box-sizing: border-box; max-width: 100%; width: 360px; display: flex; flex-wrap: wrap; gap: 8px; font: 600 13.5px Inter, system-ui, sans-serif; }
.fcg button { padding: 7px 12px; border: 1.5px solid #d0d5dd; border-radius: 999px; background: #fff; color: #344054; font: inherit; cursor: pointer; }
.fcg button[aria-pressed=true] { border-color: #0f766e; background: #f0fdfa; color: #115e59; }
.fcg button[aria-pressed=true]::before { content: "\2713  "; }
.fcg .clr { border-color: transparent; color: #1d4ed8; text-decoration: underline; }
.fcg button:focus-visible { outline: 2px solid #0f766e; outline-offset: 2px; }
const ch = [...document.querySelectorAll('.fcg [aria-pressed]')];
ch.forEach(b => b.addEventListener('click', () => b.setAttribute('aria-pressed', String(b.getAttribute('aria-pressed') !== 'true'))));
document.querySelector('.fcg .clr').addEventListener('click', () => ch.forEach(b => b.setAttribute('aria-pressed', 'false')));

44. Quantity Stepper Buttons

E-commerceNumber

A minus, number and plus group for cart quantities. The buttons are named Decrease and Increase quantity, the number is a real input with min and max, and the minus button disables itself at the minimum.

View code
<div class="qty" role="group" aria-label="Quantity">
  <button aria-label="Decrease quantity" id="q-dn">&minus;</button>
  <input id="q-v" type="number" value="1" min="1" max="10" aria-label="Quantity">
  <button aria-label="Increase quantity" id="q-up">+</button>
</div>
.qty { box-sizing: border-box; max-width: 100%; display: inline-flex; overflow: hidden; border: 1px solid #343c51; border-radius: 12px; background: #151a26; }
.qty button { width: 42px; border: 0; background: none; color: #fff; font: 600 20px Inter, system-ui, sans-serif; cursor: pointer; }
.qty button:hover { background: #1e2433; }
.qty button:disabled { color: #4a5368; cursor: default; }
.qty input { width: 48px; border: 0; border-inline: 1px solid #343c51; background: none; color: #fff; font: 700 16px Inter, sans-serif; text-align: center; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { appearance: none; }
.qty button:focus-visible, .qty input:focus-visible { outline: 2px solid #9db8ff; outline-offset: -2px; }
const v = document.getElementById('q-v'), dn = document.getElementById('q-dn'), up = document.getElementById('q-up');
function set(n) { v.value = Math.max(1, Math.min(10, n)); dn.disabled = +v.value <= 1; up.disabled = +v.value >= 10; }
dn.addEventListener('click', () => set(+v.value - 1)); up.addEventListener('click', () => set(+v.value + 1)); v.addEventListener('change', () => set(+v.value || 1));
set(1);

About these CSS Buttons

What makes a good CSS button

A button has one job: to look pressable and say what happens next. Give it a label that names the action ("Save changes", not "Submit"), at least 44 by 44 pixels of tap area on touch screens, and a focus style you can actually see. Hover effects are a bonus for mouse users; they should never be the only way to tell that something is clickable.

Button or link?

Use a <button> when the click does something on the page, such as submitting a form, opening a menu or copying text. Use an <a href> when it takes the visitor to another page. Styling an anchor to look like a button is fine; using a div with a click handler is not, because keyboards and screen readers cannot reach it.

Animating buttons without jank

Animate transform and opacity, not width, height or margins. The demos here move glows, fills and arrows with transforms or on pseudo-elements, so the button never changes size and the content around it never shifts. Keep hover transitions short, between 150 and 300 milliseconds, so the button feels responsive.

How to use these demos

Each demo is scoped with its own class prefix (.ttb-), so you can paste several into one page without collisions. Click Open in editor to change colours and text with a live preview, then copy the result. The colours use the same blue palette as this site; swap the hex values for your brand.

Frequently asked questions

Are these CSS buttons free to use?

Yes. You can copy them into personal and commercial projects. No sign-up and no attribution required.

Do they need a framework?

No. They are plain HTML and CSS. Two demos add a few lines of vanilla JavaScript for the loading and copy states.

Will they work on mobile?

Yes. They use relative layout, readable font sizes and tap areas large enough for a finger. Hover effects simply do not trigger on touch screens; the buttons still work.