AI CSS Animations

Stop Generating Button

The round stop button chat apps show while a reply streams: a rounded square in the middle, gently pulsing, with an arc spinning around the rim. Keeps an aria-label for screen readers.

Also known as: stop response button, ai stop button spinner, cancel generation button.

HTML

<button class="ldr-stop-generating-button" type="button" aria-busy="true" aria-label="Stop generating"><span aria-hidden="true"></span></button>

CSS

.ldr-stop-generating-button {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  display: grid;
  place-items: center;
  width: var(--s);
  height: var(--s);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ldr-color, #3b82f6) 14%, transparent);
  cursor: pointer;
}
.ldr-stop-generating-button::before {
  content: "";
  position: absolute;
  inset: calc(var(--s) / 16);
  box-sizing: border-box;
  border: calc(var(--s) / 16) solid transparent;
  border-top-color: var(--c);
  border-radius: 50%;
  animation: ldr-stop-generating-button-spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}
.ldr-stop-generating-button span {
  width: 32%;
  height: 32%;
  border-radius: calc(var(--s) / 18);
  background: var(--c);
  animation: ldr-stop-generating-button-pulse 2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes ldr-stop-generating-button-spin {
  to { transform: rotate(360deg); }
}
@keyframes ldr-stop-generating-button-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(0.82); }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-stop-generating-button, .ldr-stop-generating-button *, .ldr-stop-generating-button::before, .ldr-stop-generating-button::after, .ldr-stop-generating-button *::before, .ldr-stop-generating-button *::after {
    animation-duration: 3s;
  }
}

Customizing this loader

  • Color: set --ldr-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --ldr-size. Every dimension in the snippet is derived from it. Currently previewing 64px.
  • Speed: change the duration on the animation shorthand. Delays on the children are relative, so they keep their rhythm.
  • Accessibility: the root carries role="status" and an aria-label so screen readers announce the wait. The reduced-motion rule at the end slows the animation for users who asked for less motion.

Similar loaders