AI CSS Animations

I'm Not a Robot Checkbox

The verify-you're-human pattern: the box rounds into a spinner, turns twice, then shrinks away as a checkmark draws in and the shield fills. Only the look; real checks need a bot-detection service.

Also known as: captcha checkbox css, verify human checkbox, loading checkbox animation.

HTML

<label class="chk-not-a-robot">
  <input type="checkbox">
  <span class="chk-not-a-robot-slot">
    <span class="chk-not-a-robot-box"></span>
    <svg class="chk-not-a-robot-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12.5l5.5 5.5 11-11.5"/></svg>
  </span>
  <span class="chk-not-a-robot-text">I'm not a robot</span>
  <svg class="chk-not-a-robot-shield" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l7 2.8v5.4c0 4.3-2.9 8-7 9.8-4.1-1.8-7-5.5-7-9.8V5.8z"/></svg>
</label>

CSS

.chk-not-a-robot {
  --c: var(--chk-color, #3b82f6);
  font-size: var(--chk-size, 24px);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  line-height: 1.3;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  gap: 0.7em;
  width: 13.5em;
  padding: 0.8em 0.9em;
  border: 0.08em solid color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 0.55em;
  background: color-mix(in srgb, currentColor 4%, transparent);}
.chk-not-a-robot input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chk-not-a-robot-slot {
  position: relative;
  flex: none;
  width: 1.45em;
  height: 1.45em;
}
.chk-not-a-robot-box {
  position: absolute;
  inset: 0;
  border: 0.14em solid color-mix(in srgb, currentColor 40%, transparent);
  border-radius: 0.25em;
  background: color-mix(in srgb, currentColor 3%, transparent);
  transition: opacity 0.2s ease, transform 0.25s ease;
}
.chk-not-a-robot-check {
  position: absolute;
  inset: -0.1em;
  width: calc(100% + 0.2em);
  height: calc(100% + 0.2em);
  fill: none;
  stroke: var(--c);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
  transition: stroke-dashoffset 0.15s ease-in;
}
.chk-not-a-robot-text {
  flex: 1;
  font-weight: 500;
}
.chk-not-a-robot-shield {
  flex: none;
  width: 1.3em;
  height: 1.3em;
  fill: transparent;
  stroke: color-mix(in srgb, currentColor 45%, transparent);
  stroke-width: 1.6;
  stroke-linejoin: round;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.chk-not-a-robot:hover .chk-not-a-robot-box {
  border-color: var(--c);
}
.chk-not-a-robot input:checked + .chk-not-a-robot-slot .chk-not-a-robot-box {
  opacity: 0;
  transform: rotate(0deg) scale(0.3);
  animation: chk-not-a-robot-spin 1s linear;
}
.chk-not-a-robot input:checked + .chk-not-a-robot-slot .chk-not-a-robot-check {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s cubic-bezier(0.65, 0, 0.35, 1) 0.95s;
}
.chk-not-a-robot input:checked ~ .chk-not-a-robot-shield {
  fill: color-mix(in srgb, var(--c) 25%, transparent);
  stroke: var(--c);
  transition-delay: 1.1s;
}
.chk-not-a-robot input:focus-visible + .chk-not-a-robot-slot {
  outline: 0.12em solid var(--c);
  outline-offset: 0.18em;
}
@keyframes chk-not-a-robot-spin {
  0% { opacity: 1; transform: rotate(0deg) scale(1); border-radius: 0.25em; }
  18% { opacity: 1; transform: rotate(60deg) scale(0.8); border-radius: 50%; border-color: color-mix(in srgb, var(--c) 22%, transparent); border-top-color: var(--c); background: transparent; }
  82% { opacity: 1; transform: rotate(700deg) scale(0.8); border-radius: 50%; border-color: color-mix(in srgb, var(--c) 22%, transparent); border-top-color: var(--c); background: transparent; }
  100% { opacity: 0; transform: rotate(760deg) scale(0.3); border-radius: 50%; border-color: color-mix(in srgb, var(--c) 22%, transparent); border-top-color: var(--c); background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .chk-not-a-robot, .chk-not-a-robot *, .chk-not-a-robot::before, .chk-not-a-robot::after, .chk-not-a-robot *::before, .chk-not-a-robot *::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