About this snippet

Replace boring radio buttons with these selectable cards. Perfect for pricing plans or shipping options, these cards use a hidden input to remain fully functional forms while offering a much better visual experience.

Size
1.6 KB
Uses
HTML, CSS
Loads
Nothing external
Views
374
<div class="plan-selector">
  <label class="plan-card">
    <input type="radio" name="plan" checked>
    <div class="plan-content">
      <span class="plan-title">Standard</span>
      <span class="plan-cost">Free</span>
    </div>
  </label>
  <label class="plan-card">
    <input type="radio" name="plan">
    <div class="plan-content">
      <span class="plan-title">Pro</span>
      <span class="plan-cost">$19/mo</span>
    </div>
  </label>
  <label class="plan-card">
    <input type="radio" name="plan">
    <div class="plan-content">
      <span class="plan-title">Business</span>
      <span class="plan-cost">$49/mo</span>
    </div>
  </label>
</div>
.plan-selector {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 400px;
  margin: 0 auto;
}
.plan-card {
  position: relative;
  cursor: pointer;
}
.plan-card input {
  position: absolute;
  opacity: 0;
}
.plan-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  transition: all 0.2s;
  background: #fff;
}
.plan-title {
  font-weight: 600;
  color: #374151;
  font-size: 1.1rem;
}
.plan-cost {
  color: #6b7280;
}
/* Checked State */
.plan-card input:checked + .plan-content {
  border-color: #3b82f6;
  background-color: #eff6ff;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}
.plan-card input:checked + .plan-content .plan-title {
  color: #2563eb;
}
/* Hover State */
.plan-card:hover .plan-content {
  border-color: #3b82f6;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save