AI CSS Animations

Hold to Confirm Ring Button

A dark pill with a progress ring: hold it and the ring closes around the dot, then the pill turns to your color with a drawn check. Let go early and it drains back. :active drives every transition.

Also known as: hold to confirm button, press and hold button css, long press progress ring, hold to pay button.

HTML

<button class="btn-hold-confirm-ring" type="button">
  <span class="btn-hold-confirm-ring-dial" aria-hidden="true">
    <svg class="btn-hold-confirm-ring-svg" viewBox="0 0 36 36"><circle class="btn-hold-confirm-ring-track" cx="18" cy="18" r="16"/><circle class="btn-hold-confirm-ring-arc" cx="18" cy="18" r="16" pathLength="100"/></svg>
    <span class="btn-hold-confirm-ring-dot"></span>
    <svg class="btn-hold-confirm-ring-check" viewBox="0 0 24 24"><path d="M6.5 12.5l3.8 3.8 7.2-8" pathLength="1"/></svg>
  </span>
  <span class="btn-hold-confirm-ring-label"><span>Hold to pay $48.00</span><span aria-hidden="true">Payment sent</span></span>
</button>

CSS

.btn-hold-confirm-ring {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.6em;
  border: 0;
  border-radius: 0.6em;
  font: 600 var(--btn-size, 18px)/1.1 system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  --t: 1.4s;
  --surface: color-mix(in srgb, var(--c) 14%, #0e1118);
  position: relative;
  gap: 0.75em;
  padding: 0.4em 1.4em 0.4em 0.4em;
  border-radius: 2em;
  background-color: var(--surface);
  color: #fff;
  box-shadow: inset 0 1px color-mix(in srgb, #fff 10%, transparent), 0 0.6em 1.4em -0.7em color-mix(in srgb, var(--c) 60%, #000);
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1), background-color 0.3s ease;}
.btn-hold-confirm-ring-dial {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.3em;
  height: 2.3em;
}
.btn-hold-confirm-ring-dial > * { grid-area: 1 / 1; }
.btn-hold-confirm-ring-svg {
  width: 100%;
  height: 100%;
  rotate: -90deg;
  overflow: visible;
}
.btn-hold-confirm-ring-svg circle {
  fill: none;
  stroke-width: 3;
}
.btn-hold-confirm-ring-track { stroke: color-mix(in srgb, #fff 14%, transparent); }
.btn-hold-confirm-ring-arc {
  stroke: var(--c);
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  opacity: 0;
  transition: stroke-dashoffset 0.35s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.2s ease, opacity 0s linear 0.35s;
}
.btn-hold-confirm-ring-dot {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 0.22em color-mix(in srgb, var(--c) 25%, transparent);
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.2s ease;
}
.btn-hold-confirm-ring-check {
  width: 1.3em;
  height: 1.3em;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.15s ease;
}
.btn-hold-confirm-ring-label {
  display: grid;
  white-space: nowrap;
}
.btn-hold-confirm-ring-label > span {
  grid-area: 1 / 1;
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.btn-hold-confirm-ring-label > span + span {
  opacity: 0;
  transform: translateY(0.5em);
}
.btn-hold-confirm-ring:hover { background-color: color-mix(in srgb, var(--c) 22%, #0e1118); }
.btn-hold-confirm-ring:hover .btn-hold-confirm-ring-dot { transform: scale(1.15); }
.btn-hold-confirm-ring:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 0.2em;
}
.btn-hold-confirm-ring:active {
  transform: scale(0.97);
  background-color: var(--c);
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1), background-color 0.3s ease var(--t);
}
.btn-hold-confirm-ring:active .btn-hold-confirm-ring-arc {
  stroke-dashoffset: 0;
  stroke: #fff;
  opacity: 1;
  transition: stroke-dashoffset var(--t) cubic-bezier(0.45, 0, 0.7, 1), stroke 0.2s ease var(--t), opacity 0s;
}
.btn-hold-confirm-ring:active .btn-hold-confirm-ring-dot {
  transform: scale(0.6);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.15s ease var(--t);
}
.btn-hold-confirm-ring:active .btn-hold-confirm-ring-check {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s cubic-bezier(0.65, 0, 0.35, 1) calc(var(--t) + 0.1s);
}
.btn-hold-confirm-ring:active .btn-hold-confirm-ring-label > span:first-child {
  opacity: 0;
  transform: translateY(-0.5em);
  transition-delay: var(--t);
}
.btn-hold-confirm-ring:active .btn-hold-confirm-ring-label > span + span {
  opacity: 1;
  transform: none;
  transition-delay: var(--t);
}
@media (prefers-reduced-motion: reduce) {
  .btn-hold-confirm-ring,
  .btn-hold-confirm-ring:active { transform: none; }
  .btn-hold-confirm-ring-label > span { transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-hold-confirm-ring, .btn-hold-confirm-ring *, .btn-hold-confirm-ring::before, .btn-hold-confirm-ring::after, .btn-hold-confirm-ring *::before, .btn-hold-confirm-ring *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --btn-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --btn-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 18px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar buttons