AI CSS Animations

Radial Wipe Checkbox

The fill sweeps around the box like a clock hand, then the tick draws on top. A registered @property lets the conic-gradient angle transition, so unchecking winds it back the other way.

Also known as: conic gradient checkbox, clock wipe checkbox animation.

HTML

<label class="chk-radial-wipe-checkbox">
  <input type="checkbox">
  <span class="chk-radial-wipe-checkbox-box">
    <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
  </span>
  Sync across devices
</label>

CSS

@property --chk-radial-wipe-checkbox-turn {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.chk-radial-wipe-checkbox {
  --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-radial-wipe-checkbox input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chk-radial-wipe-checkbox-box {
  --chk-radial-wipe-checkbox-turn: 0deg;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  flex: none;
  width: 1.3em;
  height: 1.3em;
  border: 0.125em solid color-mix(in srgb, currentColor 38%, transparent);
  border-radius: 0.3em;
  background: conic-gradient(var(--c) var(--chk-radial-wipe-checkbox-turn), transparent 0);
  transition: --chk-radial-wipe-checkbox-turn 0.4s cubic-bezier(0.65, 0, 0.35, 1) 0.12s, border-color 0.2s ease 0.3s;
}
.chk-radial-wipe-checkbox-box svg {
  display: block;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 0.85em;
  height: 0.85em;
  stroke: #fff;
  stroke-width: 3;
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
  transition: stroke-dashoffset 0.12s ease-in;
}
.chk-radial-wipe-checkbox input:checked + .chk-radial-wipe-checkbox-box {
  --chk-radial-wipe-checkbox-turn: 360deg;
  border-color: var(--c);
  transition: --chk-radial-wipe-checkbox-turn 0.45s cubic-bezier(0.65, 0, 0.35, 1), border-color 0.2s ease;
}
.chk-radial-wipe-checkbox input:checked + .chk-radial-wipe-checkbox-box svg {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s ease-out 0.4s;
}
.chk-radial-wipe-checkbox input:focus-visible + .chk-radial-wipe-checkbox-box {
  outline: 0.125em solid var(--c);
  outline-offset: 0.18em;
}

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