AI CSS Animations

Round Checkbox

A circular checkbox: border-radius: 50% on an appearance: none input, a fill that floods in, and an L-shaped checkmark that pops with a spring overshoot. Pure CSS, no SVG.

Also known as: circle checkbox css, css checkbox rounded, how to make checkbox circle in css.

HTML

<label class="chk-round-checkbox">
  <input type="checkbox">
  Remember this device
</label>

CSS

.chk-round-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-round-checkbox input {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  flex: none;
  width: 1.375em;
  height: 1.375em;
  margin: 0;
  font: inherit;
  background: transparent;
  border: 0.125em solid color-mix(in srgb, currentColor 38%, transparent);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}
.chk-round-checkbox input::after {
  content: "";
  box-sizing: border-box;
  width: 0.36em;
  height: 0.66em;
  margin-top: -0.14em;
  border: solid #fff;
  border-width: 0 0.14em 0.14em 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease-in;
}
.chk-round-checkbox input:checked {
  background: var(--c);
  border-color: var(--c);
}
.chk-round-checkbox input:checked::after {
  transform: rotate(45deg) scale(1);
  transition: transform 0.45s cubic-bezier(0.34, 1.8, 0.64, 1) 0.05s;
}
.chk-round-checkbox input:focus-visible {
  outline: 0.125em solid var(--c);
  outline-offset: 0.18em;
}

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

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<label class="inline-flex cursor-pointer items-center gap-2.5">
  <input type="checkbox" class="grid h-[22px] w-[22px] shrink-0 cursor-pointer appearance-none place-items-center rounded-full border-2 border-gray-400 transition-colors duration-200 after:-mt-0.5 after:h-2.5 after:w-1.5 after:rotate-45 after:scale-0 after:border-b-2 after:border-r-2 after:border-white after:transition-transform after:duration-150 after:content-[''] checked:border-blue-500 checked:bg-blue-500 checked:after:scale-100 checked:after:duration-500 checked:after:ease-[cubic-bezier(.34,1.8,.64,1)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500">
  Remember this device
</label>

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