AI CSS Animations

Big Radio Button with Border Fill

Large, easy to tap radios where the ring itself does the work: on check the border thickens inward with a spring until only a small hole is left. One input, no pseudo-elements.

Also known as: make radio button bigger css, radio button border css, tailwind radio button.

HTML

<div class="rad-big-radio-border-fill" role="radiogroup" aria-label="Visibility">
  <label><input type="radio" name="rad-big-radio-border-fill" value="public" checked>Public</label>
  <label><input type="radio" name="rad-big-radio-border-fill" value="unlisted">Unlisted</label>
  <label><input type="radio" name="rad-big-radio-border-fill" value="private">Private</label>
</div>

CSS

.rad-big-radio-border-fill {
  --c: var(--rad-color, #3b82f6);
  font-size: var(--rad-size, 18px);
  display: grid;
  gap: 0.65em;
  font-family: system-ui, sans-serif;
  line-height: 1.2;
}
.rad-big-radio-border-fill label {
  display: flex;
  align-items: center;
  gap: 0.65em;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
}
.rad-big-radio-border-fill input {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 1.5em;
  height: 1.5em;
  margin: 0;
  border: 0.13em solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: border-width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease;
}
.rad-big-radio-border-fill label:hover input:not(:checked) {
  border-color: color-mix(in srgb, var(--c) 60%, transparent);
}
.rad-big-radio-border-fill input:checked {
  border-width: 0.45em;
  border-color: var(--c);
}
.rad-big-radio-border-fill input:focus-visible {
  outline: 0.1em solid var(--c);
  outline-offset: 0.15em;
}

@media (prefers-reduced-motion: reduce) {
  .rad-big-radio-border-fill, .rad-big-radio-border-fill *, .rad-big-radio-border-fill::before, .rad-big-radio-border-fill::after, .rad-big-radio-border-fill *::before, .rad-big-radio-border-fill *::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.

<div role="radiogroup" aria-label="Visibility" class="grid gap-2.5">
  <label class="flex cursor-pointer items-center gap-2.5 text-lg font-semibold">
    <input type="radio" name="visibility" value="public" checked class="h-6 w-6 cursor-pointer appearance-none rounded-full border-2 border-gray-400 transition-all duration-300 ease-[cubic-bezier(.34,1.56,.64,1)] hover:border-blue-400 checked:border-[7px] checked:border-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500">
    Public
  </label>
  <label class="flex cursor-pointer items-center gap-2.5 text-lg font-semibold">
    <input type="radio" name="visibility" value="unlisted" class="h-6 w-6 cursor-pointer appearance-none rounded-full border-2 border-gray-400 transition-all duration-300 ease-[cubic-bezier(.34,1.56,.64,1)] hover:border-blue-400 checked:border-[7px] checked:border-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500">
    Unlisted
  </label>
  <label class="flex cursor-pointer items-center gap-2.5 text-lg font-semibold">
    <input type="radio" name="visibility" value="private" class="h-6 w-6 cursor-pointer appearance-none rounded-full border-2 border-gray-400 transition-all duration-300 ease-[cubic-bezier(.34,1.56,.64,1)] hover:border-blue-400 checked:border-[7px] checked:border-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500">
    Private
  </label>
</div>

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