This toggle switch checkbox mimics a mobile on/off switch using CSS transitions.

HTML

<label class="ss-toggle">
  <input type="checkbox">
  <span></span>
</label>

CSS

.ss-toggle{
  position:relative;
  width:44px;
  height:24px;
}

.ss-toggle input{
  display:none;
}

.ss-toggle span{
  position:absolute;
  inset:0;
  background:#cbd5e1;
  border-radius:999px;
  transition:.3s;
}

.ss-toggle span::before{
  content:'';
  position:absolute;
  width:18px;
  height:18px;
  background:#fff;
  border-radius:50%;
  top:3px;
  left:3px;
  transition:.3s;
}

.ss-toggle input:checked + span{
  background:#22c55e;
}

.ss-toggle input:checked + span::before{
  transform:translateX(20px);
}

Notes

  • Mobile-style toggle
  • Smooth sliding animation
  • Popular UI pattern

Preview styles shown. Production customization recommended.

Browse More UI Components

Explore hundreds of reusable HTML & CSS UI components built for modern web projects.
Discover buttons, cards, loaders, animations, layouts, and more all with live previews and clean, copy-paste code.

Leave a Reply

Your email address will not be published. Required fields are marked *