Skip to main content

CSS Toggle Switch Generator

Create custom CSS toggle switches with a visual editor. Adjust size, color, and animation, then export the code.

#6366f1
#d1d5db
#ffffff

Preview

Wi-Fi
Bluetooth

HTML Code

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

CSS Code

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

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

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    border-radius: 50px;
    transition: background-color 0.3s ease;
}

.toggle-switch .slider::before {
    content: "";
    position: absolute;
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    border-radius: 45px;
    transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .slider {
    background-color: #6366f1;
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(24px);
}
Share this tool
📖

How to Use

Step 1

Select Design

Select Design

Select a toggle switch design template

Step 2

Customize

Customize

Adjust colors, size, roundness, animation, etc.

Step 3

Copy Code

Copy Code

Copy the HTML/CSS code

Features

Real-time Preview

Preview toggle switch behavior in real time

Various Styles

Design variations: iOS-style, Material-style, flat, and more

Smooth Animation

Achieve smooth toggle animations using CSS transitions

FAQ

A UI component that styles a checkbox as a switch. Used for ON/OFF toggling.