AI CSS Animations

Plan List Radio Cards

A billing plan list in the style of a modern SaaS checkout. One accent ring glides between the cards with a spring instead of fading, positioned by :has(:checked) and a custom property.

Also known as: radio button cards, radio button cards css, billing plan radio list, plan selector radio.

HTML

<div class="rad-plan-list-radio-cards" role="radiogroup" aria-label="Plan">
  <span class="rad-plan-list-radio-cards-ring" aria-hidden="true"></span>
  <label>
    <input type="radio" name="rad-plan-list-radio-cards" value="hobby">
    <span class="rad-plan-list-radio-cards-dot" aria-hidden="true"></span>
    <span class="rad-plan-list-radio-cards-info"><span class="rad-plan-list-radio-cards-name">Hobby</span><span class="rad-plan-list-radio-cards-desc">Personal projects</span></span>
    <span class="rad-plan-list-radio-cards-price">$0</span>
  </label>
  <label>
    <input type="radio" name="rad-plan-list-radio-cards" value="pro" checked>
    <span class="rad-plan-list-radio-cards-dot" aria-hidden="true"></span>
    <span class="rad-plan-list-radio-cards-info"><span class="rad-plan-list-radio-cards-name">Pro <span class="rad-plan-list-radio-cards-badge">Popular</span></span><span class="rad-plan-list-radio-cards-desc">Unlimited deploys, 1 TB transfer</span></span>
    <span class="rad-plan-list-radio-cards-price">$20<span class="rad-plan-list-radio-cards-per">/mo</span></span>
  </label>
  <label>
    <input type="radio" name="rad-plan-list-radio-cards" value="enterprise">
    <span class="rad-plan-list-radio-cards-dot" aria-hidden="true"></span>
    <span class="rad-plan-list-radio-cards-info"><span class="rad-plan-list-radio-cards-name">Enterprise</span><span class="rad-plan-list-radio-cards-desc">SSO, audit logs, 99.99% SLA</span></span>
    <span class="rad-plan-list-radio-cards-price">Custom</span>
  </label>
</div>

CSS

.rad-plan-list-radio-cards {
  --c: var(--rad-color, #3b82f6);
  font-size: var(--rad-size, 18px);
  --h: 2.75em;
  --gap: 0.35em;
  --i: 0;
  position: relative;
  display: grid;
  gap: var(--gap);
  width: 19.5em;
  font-family: system-ui, sans-serif;
  line-height: 1.2;
}
.rad-plan-list-radio-cards:has(label:nth-of-type(2) :checked) { --i: 1; }
.rad-plan-list-radio-cards:has(label:nth-of-type(3) :checked) { --i: 2; }
.rad-plan-list-radio-cards-ring {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: var(--h);
  box-sizing: border-box;
  border: 0.12em solid var(--c);
  border-radius: 0.75em;
  box-shadow: 0 0 0 0.25em color-mix(in srgb, var(--c) 14%, transparent), 0 0.6em 1.2em -0.8em var(--c);
  pointer-events: none;
  transform: translateY(calc(var(--i) * (var(--h) + var(--gap))));
  transition: transform 0.5s cubic-bezier(0.34, 1.3, 0.5, 1), opacity 0.2s ease;
}
.rad-plan-list-radio-cards:not(:has(:checked)) .rad-plan-list-radio-cards-ring {
  opacity: 0;
}
.rad-plan-list-radio-cards label {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75em;
  box-sizing: border-box;
  height: var(--h);
  padding: 0 0.9em;
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 0.75em;
  background: color-mix(in srgb, currentColor 2%, transparent);
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.2s ease;
}
.rad-plan-list-radio-cards label:hover {
  border-color: color-mix(in srgb, currentColor 25%, transparent);
}
.rad-plan-list-radio-cards label:has(:checked) {
  background: color-mix(in srgb, var(--c) 7%, transparent);
}
.rad-plan-list-radio-cards input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.rad-plan-list-radio-cards-dot {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 1em;
  height: 1em;
  border: 0.1em solid color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 50%;
  transition: border-color 0.2s ease;
}
.rad-plan-list-radio-cards-dot::after {
  content: "";
  width: 0.46em;
  height: 0.46em;
  border-radius: 50%;
  background: var(--c);
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rad-plan-list-radio-cards input:checked + .rad-plan-list-radio-cards-dot {
  border-color: var(--c);
}
.rad-plan-list-radio-cards input:checked + .rad-plan-list-radio-cards-dot::after {
  transform: scale(1);
}
.rad-plan-list-radio-cards-info {
  display: grid;
  gap: 0.12em;
  min-width: 0;
}
.rad-plan-list-radio-cards-name {
  display: flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.88em;
  font-weight: 650;
}
.rad-plan-list-radio-cards-badge {
  padding: 0.18em 0.5em;
  border-radius: 99em;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rad-plan-list-radio-cards-desc {
  overflow: hidden;
  font-size: 0.7em;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: color-mix(in srgb, currentColor 55%, transparent);
}
.rad-plan-list-radio-cards-price {
  font-size: 0.92em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rad-plan-list-radio-cards-per {
  font-size: 0.75em;
  font-weight: 500;
  color: color-mix(in srgb, currentColor 55%, transparent);
}
.rad-plan-list-radio-cards label:has(:focus-visible) {
  outline: 0.12em dashed var(--c);
  outline-offset: 0.35em;
}
@media (prefers-reduced-motion: reduce) {
  .rad-plan-list-radio-cards *,
  .rad-plan-list-radio-cards *::before,
  .rad-plan-list-radio-cards *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

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