AI CSS Animations

Animated Circle Checkmark Checkbox

The success-style checkmark as a checkbox: a ring traces itself around the circle, the tick draws inside it, and the icon gives a small bump when it lands. Two SVG strokes, no fill.

Also known as: success checkmark animation css, checkmark circle animation, circle tick animation.

HTML

<label class="chk-animated-circle-checkmark">
  <input type="checkbox">
  <svg class="chk-animated-circle-checkmark-icon" viewBox="0 0 26 26" aria-hidden="true">
    <circle class="chk-animated-circle-checkmark-track" cx="13" cy="13" r="11"/>
    <circle class="chk-animated-circle-checkmark-ring" cx="13" cy="13" r="11"/>
    <path class="chk-animated-circle-checkmark-tick" d="M8 13.5l3.5 3.5L18.5 9.5"/>
  </svg>
  Mark as read
</label>

CSS

.chk-animated-circle-checkmark {
  --c: var(--chk-color, #3b82f6);
  font-size: var(--chk-size, 24px);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chk-animated-circle-checkmark input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chk-animated-circle-checkmark-icon {
  display: block;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  stroke-width: 2;
}
.chk-animated-circle-checkmark-track {
  stroke: color-mix(in srgb, currentColor 38%, transparent);
}
.chk-animated-circle-checkmark-ring {
  stroke: var(--c);
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
  transform: rotate(-90deg);
  transform-box: fill-box;
  transform-origin: center;
  transition: stroke-dashoffset 0.3s ease-in 0.1s;
}
.chk-animated-circle-checkmark-tick {
  stroke: var(--c);
  stroke-width: 2.4;
  stroke-dasharray: 17;
  stroke-dashoffset: 17;
  transition: stroke-dashoffset 0.12s ease-in;
}
.chk-animated-circle-checkmark input:checked + .chk-animated-circle-checkmark-icon {
  animation: chk-animated-circle-checkmark-bump 0.35s ease 0.62s;
}
.chk-animated-circle-checkmark input:checked + .chk-animated-circle-checkmark-icon .chk-animated-circle-checkmark-ring {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}
.chk-animated-circle-checkmark input:checked + .chk-animated-circle-checkmark-icon .chk-animated-circle-checkmark-tick {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s cubic-bezier(0.3, 0, 0.2, 1) 0.38s;
}
.chk-animated-circle-checkmark input:focus-visible + .chk-animated-circle-checkmark-icon {
  outline: 0.125em solid var(--c);
  outline-offset: 0.18em;
}
@keyframes chk-animated-circle-checkmark-bump {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.14); }
}

@media (prefers-reduced-motion: reduce) {
  .chk-animated-circle-checkmark, .chk-animated-circle-checkmark *, .chk-animated-circle-checkmark::before, .chk-animated-circle-checkmark::after, .chk-animated-circle-checkmark *::before, .chk-animated-circle-checkmark *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --chk-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --chk-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 24px.
  • 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 checkboxes