CSS Toggle Switch Generator

Build custom toggle switches with live preview. Generate pure CSS + HTML code.

Presets
Dimensions
51px
31px
15.5px
200ms
Colors

#34c759

#e5e5ea

#ffffff

Live Preview
ON

Click the toggle to interact

Generated Code
/* Toggle Switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-track {
  position: relative;
  width: 51px;
  height: 31px;
  background-color: #e5e5ea;
  border-radius: 15.5px;
  transition: background-color 200ms ease;
  cursor: pointer;
}

.toggle-switch input:checked + .toggle-track {
  background-color: #34c759;
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background-color: #ffffff;
  border-radius: 13.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 200ms ease;
}

.toggle-switch input:checked + .toggle-track .toggle-knob {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}