18 CSS Radio Button Designs

Pill Slider

Three-option pill where the active background slides smoothly between selections — perfect for plan toggles and view switchers.

Pure CSS MIT licensed

Pill Slider the 2nd of 18 designs in the 18 CSS Radio Button Designs collection. The design is implemented in pure CSS — no JavaScript required. Copy the HTML and CSS panels below into your project. Because the demo is pure CSS, it works in any framework or templating engine you happen to use. The design honours prefers-reduced-motion and uses real semantic markup, so it ships accessibility-ready out of the box.

Live preview

Open in playground

The code

<fieldset class="crb-pill">
  <legend class="crb-sr">Billing</legend>
  <input type="radio" name="crb-pill" id="crb-pill-1" checked />
  <label for="crb-pill-1">Monthly</label>
  <input type="radio" name="crb-pill" id="crb-pill-2" />
  <label for="crb-pill-2">Yearly</label>
  <input type="radio" name="crb-pill" id="crb-pill-3" />
  <label for="crb-pill-3">Forever</label>
  <span class="crb-pill-thumb"></span>
</fieldset>
.crb-pill {
  display: inline-flex; position: relative; padding: 4px;
  background: #1a1a28; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
}
.crb-pill input { appearance: none; -webkit-appearance: none; position: absolute; opacity: 0; }
.crb-pill label {
  flex: 1 1 0; min-width: 80px;
  position: relative; z-index: 1;
  padding: 8px 16px;
  font: 600 12px/1 system-ui, sans-serif; color: #b8b6d4;
  text-align: center;
  cursor: pointer; transition: color 0.25s;
  border-radius: 999px;
}
.crb-pill input:checked + label { color: #fff; }
.crb-pill-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(33.333% - 2.667px);
  background: linear-gradient(135deg, #7c6cff, #a78bfa);
  border-radius: 999px; z-index: 0;
  transition: transform 0.4s cubic-bezier(0.65,0,0.35,1);
}
#crb-pill-2:checked ~ .crb-pill-thumb { transform: translateX(100%); }
#crb-pill-3:checked ~ .crb-pill-thumb { transform: translateX(200%); }

.crb-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

Search CodeFronts

Loading…