AI CSS Animations

Radio Button with Checkmark

Radios that show a tick instead of a dot. The circle floods with the accent, then a white checkmark draws itself with stroke-dashoffset. Each option carries a line of helper text.

Also known as: radio button with tick css, check circle radio button, round checkmark radio.

HTML

<div class="rad-checkmark-radio" role="radiogroup" aria-label="Order type">
  <label><input type="radio" name="rad-checkmark-radio" value="pickup" checked><span class="rad-checkmark-radio-mark" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="rad-checkmark-radio-text">Pickup<small>Ready in 20 minutes</small></span></label>
  <label><input type="radio" name="rad-checkmark-radio" value="delivery"><span class="rad-checkmark-radio-mark" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="rad-checkmark-radio-text">Delivery<small>About 45 minutes</small></span></label>
  <label><input type="radio" name="rad-checkmark-radio" value="table"><span class="rad-checkmark-radio-mark" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="rad-checkmark-radio-text">Dine in<small>Book a table</small></span></label>
</div>

CSS

.rad-checkmark-radio {
  --c: var(--rad-color, #3b82f6);
  font-size: var(--rad-size, 18px);
  display: grid;
  gap: 0.75em;
  font-family: system-ui, sans-serif;
  line-height: 1.2;
}
.rad-checkmark-radio label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7em;
  cursor: pointer;
}
.rad-checkmark-radio input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.rad-checkmark-radio-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 1.45em;
  height: 1.45em;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.12em color-mix(in srgb, currentColor 30%, transparent);
  transition: box-shadow 0.25s ease;
}
.rad-checkmark-radio-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--c);
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rad-checkmark-radio-mark svg {
  position: relative;
  display: block;
  width: 0.95em;
  height: 0.95em;
  fill: none;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.12s ease;
}
.rad-checkmark-radio label:hover input:not(:checked) + .rad-checkmark-radio-mark {
  box-shadow: inset 0 0 0 0.12em color-mix(in srgb, var(--c) 60%, transparent);
}
.rad-checkmark-radio input:checked + .rad-checkmark-radio-mark {
  box-shadow: inset 0 0 0 0.12em var(--c);
}
.rad-checkmark-radio input:checked + .rad-checkmark-radio-mark::before {
  transform: scale(1);
}
.rad-checkmark-radio input:checked + .rad-checkmark-radio-mark svg {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s ease 0.15s;
}
.rad-checkmark-radio-text {
  display: grid;
  gap: 0.15em;
  font-weight: 600;
}
.rad-checkmark-radio-text small {
  font-size: 0.75em;
  font-weight: 400;
  color: color-mix(in srgb, currentColor 55%, transparent);
}
.rad-checkmark-radio input:focus-visible + .rad-checkmark-radio-mark {
  outline: 0.12em solid var(--c);
  outline-offset: 0.18em;
}

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

Customizing this snippet

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