CSS Radio Cards

Large, clickable option cards built on real radio buttons, highlighted with :has().

  • radio
  • cards
  • choice
  • has
  • selection
HTML
<div class="radio-cards">
  <label><input type="radio" name="plan" checked><strong>Monthly</strong><span>$9 / month</span></label>
  <label><input type="radio" name="plan"><strong>Yearly</strong><span>$90 / year</span></label>
</div>
CSS
.radio-cards {
  display: flex;
  gap: 10px;
  font-family: system-ui, sans-serif;
}

.radio-cards label {
  position: relative;
  display: grid;
  flex: 1 1 0;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

/* Keep the radio accessible but invisible */
.radio-cards input {
  position: absolute;
  opacity: 0;
}

.radio-cards strong {
  color: #0f172a;
  font-size: 15px;
}

.radio-cards span {
  color: #64748b;
  font-size: 13px;
}

.radio-cards label:has(:checked) {
  border-color: #0ea5e9;
  background: #f0f9ff;
}

.radio-cards label:has(:focus-visible) {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

About this CSS Radio Cards

This CSS Radio Cards is 45 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses transitions, CSS Grid, Flexbox and the :has() selector. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #e2e8f0
  • #fff
  • #0f172a
  • #64748b
  • #0ea5e9
  • #f0f9ff

How to use this radio cards

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .radio-cards class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback