AI CSS Animations

Pricing Plan Radio Cards

Three plan cards that act as one radio group. The chosen card lifts, gains an accent ring and a tinted fill, and a check badge pops onto its corner with a springy scale.

Also known as: radio button cards css, pricing plan selector css, plan picker radio.

HTML

<div class="rad-pricing-plan-cards" role="radiogroup" aria-label="Plan">
  <label>
    <input type="radio" name="rad-pricing-plan-cards" value="basic">
    <span class="rad-pricing-plan-cards-card">
      <span class="rad-pricing-plan-cards-name">Basic</span>
      <span class="rad-pricing-plan-cards-price">$0<small>/mo</small></span>
      <svg class="rad-pricing-plan-cards-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
    </span>
  </label>
  <label>
    <input type="radio" name="rad-pricing-plan-cards" value="pro" checked>
    <span class="rad-pricing-plan-cards-card">
      <span class="rad-pricing-plan-cards-name">Pro</span>
      <span class="rad-pricing-plan-cards-price">$12<small>/mo</small></span>
      <svg class="rad-pricing-plan-cards-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
    </span>
  </label>
  <label>
    <input type="radio" name="rad-pricing-plan-cards" value="team">
    <span class="rad-pricing-plan-cards-card">
      <span class="rad-pricing-plan-cards-name">Team</span>
      <span class="rad-pricing-plan-cards-price">$29<small>/mo</small></span>
      <svg class="rad-pricing-plan-cards-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>
    </span>
  </label>
</div>

CSS

.rad-pricing-plan-cards {
  --c: var(--rad-color, #3b82f6);
  font-size: var(--rad-size, 18px);
  display: inline-flex;
  gap: 0.7em;
  font-family: system-ui, sans-serif;
  line-height: 1.2;
}
.rad-pricing-plan-cards label {
  position: relative;
  cursor: pointer;
}
.rad-pricing-plan-cards input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.rad-pricing-plan-cards-card {
  position: relative;
  display: grid;
  gap: 0.3em;
  box-sizing: border-box;
  width: 5.6em;
  padding: 0.8em 0.85em;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 0.8em;
  background: color-mix(in srgb, currentColor 3%, transparent);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}
.rad-pricing-plan-cards label:hover .rad-pricing-plan-cards-card {
  border-color: color-mix(in srgb, var(--c) 50%, transparent);
}
.rad-pricing-plan-cards-name {
  font-size: 0.8em;
  font-weight: 600;
  color: color-mix(in srgb, currentColor 65%, transparent);
  transition: color 0.25s ease;
}
.rad-pricing-plan-cards-price {
  font-size: 1.4em;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.rad-pricing-plan-cards-price small {
  font-size: 0.5em;
  font-weight: 500;
  color: color-mix(in srgb, currentColor 55%, transparent);
}
.rad-pricing-plan-cards-check {
  position: absolute;
  top: -0.5em;
  right: -0.5em;
  width: 1.3em;
  height: 1.3em;
  padding: 0.22em;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--c);
  fill: none;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: scale(0) rotate(-45deg);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rad-pricing-plan-cards input:checked + .rad-pricing-plan-cards-card {
  transform: translateY(-0.25em);
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 8%, transparent);
  box-shadow: 0 0 0 1px var(--c), 0 0.6em 1.2em -0.6em color-mix(in srgb, var(--c) 70%, transparent);
}
.rad-pricing-plan-cards input:checked + .rad-pricing-plan-cards-card .rad-pricing-plan-cards-name {
  color: var(--c);
}
.rad-pricing-plan-cards input:checked + .rad-pricing-plan-cards-card .rad-pricing-plan-cards-check {
  transform: scale(1) rotate(0deg);
}
.rad-pricing-plan-cards input:focus-visible + .rad-pricing-plan-cards-card {
  outline: 0.12em solid var(--c);
  outline-offset: 0.2em;
}

@media (prefers-reduced-motion: reduce) {
  .rad-pricing-plan-cards, .rad-pricing-plan-cards *, .rad-pricing-plan-cards::before, .rad-pricing-plan-cards::after, .rad-pricing-plan-cards *::before, .rad-pricing-plan-cards *::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