Free CSS Generator

Generate CSSToggle Switches

Customize size, colors, shape, and transition speed. Get copy-paste HTML, CSS, and React code instantly — no sign-up required.

🎨

Full Color Control

Pick any on/off color and knob color with a visual color picker for pixel-perfect switches.

📐

Size & Shape Options

Choose from small, medium, and large presets, with pill, rounded, or square border-radius styles.

Instant Code Export

Copy clean HTML, CSS, or React/JSX code with one click — ready to drop into any project.

Customize

Size
Shape
Transition

Preview — click to toggle

State: ON

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 32px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #d1d5db;
  border-radius: 9999px;
  transition: background-color 300ms ease;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  width: 24px;
  height: 24px;
  left: 4px;
  top: 4px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 300ms ease;
}

input:checked + .toggle-slider {
  background-color: #3b82f6;
}

input:checked + .toggle-slider::before {
  transform: translateX(28px);
}

input:focus-visible + .toggle-slider {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

Frequently Asked Questions

Everything you need to know about Toggle Switch Generator.