Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <label class="checkbox">
    <input type="checkbox">
    <svg viewBox="0 0 28 28">
        <path d="M3.5 8.49964C3.5 5.73822 5.73822 3.5 8.49964 3.5C10.3275 3.5 12.3499 3.5 14 3.5C15.6501 3.5 17.6725 3.5 19.5004 3.5C22.2618 3.5 24.5 5.73822 24.5 8.49964C24.5 10.3275 24.5 12.3499 24.5 14C24.5 15.6501 24.5 17.6725 24.5 19.5004C24.5 22.2618 22.2618 24.5 19.5004 24.5C17.6725 24.5 15.6501 24.5 14 24.5C12.3499 24.5 10.3275 24.5 8.49964 24.5C5.73822 24.5 3.5 22.2618 3.5 19.5004C3.5 17.6725 3.5 15.6501 3.5 14C3.5 12.3499 3.5 10.3275 3.5 8.49964Z" />
    </svg>
    <svg class="tick" viewBox="0 0 12 10">
        <path d="M1.5 5.5L4.5 8.5L10.5 1.5" />
    </svg>
</label>

<label class="radio">
    <input type="radio" name="radio" value="1" checked>
    <svg viewBox="0 0 28 28">
        <path d="M24.5 14C24.5 19.799 19.799 24.5 14 24.5C8.20101 24.5 3.5 19.799 3.5 14C3.5 8.20101 8.20101 3.5 14 3.5C19.799 3.5 24.5 8.20101 24.5 14Z" />
    </svg>
    <svg class="inner" viewBox="0 0 28 28">
        <path d="M24.5 14C24.5 19.799 19.799 24.5 14 24.5C8.20101 24.5 3.5 19.799 3.5 14C3.5 8.20101 8.20101 3.5 14 3.5C19.799 3.5 24.5 8.20101 24.5 14Z" />
    </svg>
</label>

<label class="radio">
    <input type="radio" name="radio" value="2">
    <svg viewBox="0 0 28 28">
        <path d="M24.5 14C24.5 19.799 19.799 24.5 14 24.5C8.20101 24.5 3.5 19.799 3.5 14C3.5 8.20101 8.20101 3.5 14 3.5C19.799 3.5 24.5 8.20101 24.5 14Z" />
    </svg>
    <svg class="inner" viewBox="0 0 28 28">
        <path d="M24.5 14C24.5 19.799 19.799 24.5 14 24.5C8.20101 24.5 3.5 19.799 3.5 14C3.5 8.20101 8.20101 3.5 14 3.5C19.799 3.5 24.5 8.20101 24.5 14Z" />
    </svg>
</label>

<label class="switch">
    <input type="checkbox">
    <svg viewBox="0 0 36 18">
        <path d="M18 9C18 13.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9C0 4.02944 4.02944 0 9 0C13.9706 0 18 4.02944 18 9Z" />
    </svg>
</label>

<!-- dribbble - twitter -->
<a class="dribbble" href="https://dribbble.com/ai" target="_blank"><img src="https://cdn.dribbble.com/assets/dribbble-ball-mark-2bd45f09c2fb58dbbfb44766d5d1d07c5a12972d602ef8b32204d28fa3dda554.svg" alt=""></a>
<a class="twitter" target="_blank" href="https://twitter.com/aaroniker_me"><svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72"><path d="M67.812 16.141a26.246 26.246 0 0 1-7.519 2.06 13.134 13.134 0 0 0 5.756-7.244 26.127 26.127 0 0 1-8.313 3.176A13.075 13.075 0 0 0 48.182 10c-7.229 0-13.092 5.861-13.092 13.093 0 1.026.118 2.021.338 2.981-10.885-.548-20.528-5.757-26.987-13.679a13.048 13.048 0 0 0-1.771 6.581c0 4.542 2.312 8.551 5.824 10.898a13.048 13.048 0 0 1-5.93-1.638c-.002.055-.002.11-.002.162 0 6.345 4.513 11.638 10.504 12.84a13.177 13.177 0 0 1-3.449.457c-.846 0-1.667-.078-2.465-.231 1.667 5.2 6.499 8.986 12.23 9.09a26.276 26.276 0 0 1-16.26 5.606A26.21 26.21 0 0 1 4 55.976a37.036 37.036 0 0 0 20.067 5.882c24.083 0 37.251-19.949 37.251-37.249 0-.566-.014-1.134-.039-1.694a26.597 26.597 0 0 0 6.533-6.774z"></path></svg></a>
              
            
!

CSS

              
                .checkbox,
.radio,
.switch {
    --toggle: #fff;
    --toggle-active: #275EFE;
    --toggle-border: #BBC1E1;
    --toggle-border-hover: #A6ACCD;
    --toggle-border-active: #275EFE;
    --toggle-inner: #fff;
    --switch: #D1D6EE;
    --switch-hover: #CACFE6;
    --switch-active: #275EFE;
    --switch-dot: #fff;
    --switch-dot-shadow: #{rgba(#00093D, .1)};
    position: relative;
    input {
        display: block;
        -webkit-tap-highlight-color: transparent;
        -webkit-appearance: none;
        outline: none;
        border: none;
        cursor: pointer;
        padding: 0;
        margin: 0;
        width: var(--input-width, 22px);
        height: var(--input-height, 22px);
    }
    svg {
        fill: var(--svg-fill, none);
        stroke: var(--svg-stroke, none);
        stroke-width: var(--svg-stroke-width, 0);
        stroke-linecap: round;
        stroke-linejoin: round;
        display: block;
        width: var(--svg-width, 28px);
        height: var(--svg-height, 28px);
        position: absolute;
        top: var(--svg-top, -3px);
        left: var(--svg-left, -3px);
        pointer-events: none;
        transform: scale(var(--svg-scale, 1)) translateZ(0);
        transition: stroke .3s, fill .3s, stroke-dashoffset .15s ease var(--svg-delay, 0s), transform var(--svg-transform-duration, 0s);
    }
}

.checkbox,
.radio {
    --svg-fill: var(--toggle);
    --svg-stroke: var(--toggle-border);
    --svg-stroke-width: 1px;
    input {
        &:hover {
            & + svg {
                --svg-stroke: var(--toggle-border-hover);
            }
        }
        &:checked {
            & + svg {
                --svg-fill: var(--toggle-active);
                --svg-stroke: var(--toggle-border-active);
            }
        }
    }
}

.checkbox {
    .tick {
        --svg-width: 12px;
        --svg-height: 10px;
        --svg-fill: none;
        --svg-stroke: var(--toggle-inner);
        --svg-stroke-width: 2px;
        --svg-top: 6px;
        --svg-left: 5px;
        stroke-dasharray: 14px;
        stroke-dashoffset: var(--svg-offset, 14px);
    }
    input {
        &:checked {
            & + svg {
                & + .tick {
                    --svg-offset: 0;
                    --svg-delay: .15s;
                }
            }
        }
    }
}

.radio {
    --svg-transform-duration: .1s;
    input {
        &:checked {
            & + svg {
                & + .inner {
                    --svg-scale: 1;
                }
            }
        }
    }
    .inner {
        --svg-fill: var(--toggle-inner);
        --svg-stroke-width: 0;
        --svg-width: 14px;
        --svg-height: 14px;
        --svg-top: 4px;
        --svg-left: 4px;
        --svg-scale: 0;
    }
}

.switch {
    --input-width: 40px;
    --svg-width: 36px;
    --svg-height: 18px;
    --svg-top: 2px;
    --svg-left: 2px;
    --svg-fill: var(--switch-dot);
    input {
        background: var(--b, var(--switch));
        border-radius: 11px;
        transition: background .3s;
        &:hover {
            --b: var(--switch-hover);
        }
        &:checked {
            --b: var(--switch-active);
            & + svg {
                transform: scaleX(-1);
            }
        }
    }
    &.active {
        input {
            --b: var(--switch-active);
            &:checked {
                --b: var(--switch);
            }
        }
    }
    svg {
        filter: drop-shadow(0 .5px .5px var(--switch-dot-shadow));
    }
}

html {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

* {
    box-sizing: inherit;
    &:before,
    &:after {
        box-sizing: inherit;
    }
}

// Center & dribbble
body {
    min-height: 100vh;
    display: flex;
    font-family: 'Inter', Arial;
    justify-content: center;
    align-items: center;
    background: #F6F8FF;
    & > label {
        margin: 0 16px;
        &.radio {
            margin: 0 4px;
        }
    }
    .dribbble {
        position: fixed;
        display: block;
        right: 20px;
        bottom: 20px;
        img {
            display: block;
            height: 28px;
        }
    }
    .twitter {
        position: fixed;
        display: block;
        right: 64px;
        bottom: 14px;
        svg {
            width: 32px;
            height: 32px;
            fill: #1da1f2;
        }
    }
}
              
            
!

JS

              
                gsap.registerPlugin(MorphSVGPlugin);

document.querySelectorAll('.checkbox').forEach(element => {

    let path = element.querySelector('path'),
        input = element.querySelector('input')

    element.addEventListener('pointerdown', e => {
        if(element.classList.contains('active')) {
            return
        }
        gsap.to(path, {
            morphSVG: 'M3.76792 8.316C3.29262 5.68859 5.68858 3.29262 8.316 3.76792C10.2859 4.12429 12.3921 4.41667 14 4.41667C15.6079 4.41667 17.7141 4.12429 19.684 3.76792C22.3114 3.29262 24.7074 5.68858 24.2321 8.316C23.8757 10.2859 23.5833 12.3921 23.5833 14C23.5833 15.6079 23.8757 17.7141 24.2321 19.684C24.7074 22.3114 22.3114 24.7074 19.684 24.2321C17.7141 23.8757 15.6079 23.5833 14 23.5833C12.3921 23.5833 10.2859 23.8757 8.316 24.2321C5.68859 24.7074 3.29262 22.3114 3.76792 19.684C4.12429 17.7141 4.41667 15.6079 4.41667 14C4.41667 12.3921 4.12429 10.2859 3.76792 8.316Z',
            duration: .15
        })
    })

    element.addEventListener('click', e => {

        if(element.classList.contains('active')) {
            return
        }

        element.classList.add('active')

        gsap.fromTo(path, {
            morphSVG: 'M3.76792 8.316C3.29262 5.68859 5.68858 3.29262 8.316 3.76792C10.2859 4.12429 12.3921 4.41667 14 4.41667C15.6079 4.41667 17.7141 4.12429 19.684 3.76792C22.3114 3.29262 24.7074 5.68858 24.2321 8.316C23.8757 10.2859 23.5833 12.3921 23.5833 14C23.5833 15.6079 23.8757 17.7141 24.2321 19.684C24.7074 22.3114 22.3114 24.7074 19.684 24.2321C17.7141 23.8757 15.6079 23.5833 14 23.5833C12.3921 23.5833 10.2859 23.8757 8.316 24.2321C5.68859 24.7074 3.29262 22.3114 3.76792 19.684C4.12429 17.7141 4.41667 15.6079 4.41667 14C4.41667 12.3921 4.12429 10.2859 3.76792 8.316Z',
            duration: .15
        }, {
            morphSVG: 'M3.5 8.49964C3.5 5.73822 5.73822 3.5 8.49964 3.5C10.3275 3.5 12.3499 3.5 14 3.5C15.6501 3.5 17.6725 3.5 19.5004 3.5C22.2618 3.5 24.5 5.73822 24.5 8.49964C24.5 10.3275 24.5 12.3499 24.5 14C24.5 15.6501 24.5 17.6725 24.5 19.5004C24.5 22.2618 22.2618 24.5 19.5004 24.5C17.6725 24.5 15.6501 24.5 14 24.5C12.3499 24.5 10.3275 24.5 8.49964 24.5C5.73822 24.5 3.5 22.2618 3.5 19.5004C3.5 17.6725 3.5 15.6501 3.5 14C3.5 12.3499 3.5 10.3275 3.5 8.49964Z',
            duration: .8,
            ease: 'elastic.out(1, .25)',
            onComplete() {
                element.classList.remove('active')
            }
        })

    })

})

document.querySelectorAll('.radio').forEach(element => {

    let path = element.querySelectorAll('path'),
        input = element.querySelector('input')

    element.addEventListener('pointerdown', e => {
        if(element.classList.contains('active')) {
            return
        }
        gsap.to(path, {
            morphSVG: 'M25.5 14C25.5 19.799 19.799 23.5 14 23.5C8.20101 23.5 2.5 19.799 2.5 14C2.5 8.20101 8.20101 4.5 14 4.5C19.799 4.5 25.5 8.20101 25.5 14Z',
            duration: .15
        })
    })

    element.addEventListener('click', e => {

        if(element.classList.contains('active')) {
            return
        }

        element.classList.add('active')

        gsap.fromTo(path, {
            morphSVG: 'M25.5 14C25.5 19.799 19.799 23.5 14 23.5C8.20101 23.5 2.5 19.799 2.5 14C2.5 8.20101 8.20101 4.5 14 4.5C19.799 4.5 25.5 8.20101 25.5 14Z',
            duration: .15
        }, {
            keyframes: [{
                morphSVG: 'M23.5 14C23.5 19.799 19.799 25.5 14 25.5C8.20101 25.5 4.5 19.799 4.5 14C4.5 8.20101 8.20101 2.5 14 2.5C19.799 2.5 23.5 8.20101 23.5 14Z',
                duration: .15
            }, {
                morphSVG: 'M24.5 14C24.5 19.799 19.799 24.5 14 24.5C8.20101 24.5 3.5 19.799 3.5 14C3.5 8.20101 8.20101 3.5 14 3.5C19.799 3.5 24.5 8.20101 24.5 14Z',
                duration: .6,
                ease: 'elastic.out(1, .6)',
                onComplete() {
                    element.classList.remove('active')
                }
            }]
        })

    })

})

document.querySelectorAll('.switch').forEach(element => {

    let path = element.querySelector('path'),
        input = element.querySelector('input')

    element.addEventListener('mouseenter', e => {
        if(element.classList.contains('active')) {
            return
        }
        gsap.to(path, {
            morphSVG: 'M20 9C20 13.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9C0 4.02944 4.02944 0 9 0C13.9706 0 20 5.02944 20 9Z',
            duration: .15
        })
    })

    element.addEventListener('mouseleave', e => {
        if(element.classList.contains('active')) {
            return
        }
        gsap.to(path, {
            morphSVG: 'M18 9C18 13.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9C0 4.02944 4.02944 0 9 0C13.9706 0 18 4.02944 18 9Z',
            duration: .15
        })
    })

    element.addEventListener('click', e => {

        e.preventDefault()

        if(element.classList.contains('active')) {
            return
        }

        element.classList.add('active')

        gsap.to(path, {
            keyframes: [{
                morphSVG: 'M36 9C36 15.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9C0 4.02944 4.02944 0 9 0C13.9706 0 36 2.02944 36 9Z',
                duration: .15
            }, {
                morphSVG: 'M35.9954 9C35.9954 13.9706 31.9659 18 26.9954 18C22.0248 18 23.9954 12.9706 23.9954 9C23.9954 5.02944 22.0248 0 26.9954 0C31.9659 0 35.9954 4.02944 35.9954 9Z',
                duration: .15
            }, {
                morphSVG: 'M36 9C36 13.9706 31.9706 18 27 18C22.0294 18 18 13.9706 18 9C18 4.02944 22.0294 0 27 0C31.9706 0 36 4.02944 36 9Z',
                duration: .5,
                ease: 'elastic.out(1, .8)',
                onComplete() {
                    input.checked = !input.checked
                    gsap.set(path, {
                        morphSVG: 'M18 9C18 13.9706 13.9706 18 9 18C4.02944 18 0 13.9706 0 9C0 4.02944 4.02944 0 9 0C13.9706 0 18 4.02944 18 9Z'
                    })
                    element.classList.remove('active')
                }
            }]
        })

    })

})

              
            
!
999px

Console