AI CSS Animations

Hand-Drawn Sketch Checkbox

A wobbly pencil box with a quick scribbled tick that overshoots the corner, like marking a paper form. The tick is one SVG stroke that starts slow and flicks fast, and the box gives a small jolt.

Also known as: sketch checkbox css, hand drawn checkmark, scribble checkbox.

HTML

<label class="chk-hand-drawn-checkbox">
  <input type="checkbox">
  <svg class="chk-hand-drawn-checkbox-icon" viewBox="0 0 32 32" aria-hidden="true">
    <path class="chk-hand-drawn-checkbox-box" d="M5.5 6.2c6.6-1.1 14.3-.9 21.4-.2.7 6.8.8 13.7-.1 20.6-7.2.8-14.5.7-21.3-.1-.9-6.7-1-13.6 0-20.3z"/>
    <path class="chk-hand-drawn-checkbox-tick" d="M8 16.5c2.3 1.4 4 3.4 5.4 6.2 3.6-8.3 9.5-15.1 16.6-20.2"/>
  </svg>
  <span class="chk-hand-drawn-checkbox-text">Sign me up</span>
</label>

CSS

.chk-hand-drawn-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;
  gap: 0.5em;}
.chk-hand-drawn-checkbox input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.chk-hand-drawn-checkbox-icon {
  display: block;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  width: 1.75em;
  height: 1.75em;
  overflow: visible;
}
.chk-hand-drawn-checkbox-box {
  stroke: currentColor;
  stroke-width: 1.8;
  opacity: 0.75;
}
.chk-hand-drawn-checkbox-tick {
  stroke: var(--c);
  stroke-width: 3.2;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  transition: stroke-dashoffset 0.2s ease-in;
}
.chk-hand-drawn-checkbox-text {
  font-family: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", cursive;
  font-size: 1.1em;
}
.chk-hand-drawn-checkbox input:checked + .chk-hand-drawn-checkbox-icon {
  animation: chk-hand-drawn-checkbox-jolt 0.4s ease-out 0.3s;
}
.chk-hand-drawn-checkbox input:checked + .chk-hand-drawn-checkbox-icon .chk-hand-drawn-checkbox-tick {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.7, 0, 0.3, 1);
}
.chk-hand-drawn-checkbox input:focus-visible + .chk-hand-drawn-checkbox-icon {
  outline: 0.1em dashed var(--c);
  outline-offset: 0.1em;
  border-radius: 0.2em;
}
@keyframes chk-hand-drawn-checkbox-jolt {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(-6deg) scale(1.05); }
  65% { transform: rotate(3deg); }
}

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