Pen Settings



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


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <h1>Switch Toggle</h1>

<div class="switch">
    <input id="switch__input" type="checkbox" />
    <label for="switch__input">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Inde igitur, inquit, ordiendum est. Nihil acciderat ei, quod nollet, nisi quod anulum, quo delectabatur, in mari abiecerat.


                /* basic reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;

/* just for presentation */
body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    background-color: #e8f5f7;

    h1 {
        font-size: 4em;
        margin-bottom: 1em;

    .switch {
        max-width: 800px;
        padding: 2em;
        margin: 0 2em;
        background: white;
        border-radius: 1em;
        box-shadow: 0 0 1em rgba(0, 0, 0, 0.2);

/* Switch */
.switch {
    /* overall size */
    --size: 1.5em;

    /* Finetune switch */
    --height: 2em;
    --width: 4em;
    --border: 0.15em;
    --font-size: 1em;
    --switch-color-checked: darkcyan;
    --switch-color-unchecked: lightgrey;
    --dot-color-checked: white;
    --dot-color-unchecked: white;

    p {
        font-size: var(--font-size);
        letter-spacing: 0.05em;
        font-weight: 300;
        line-height: 1.4em;
        color: #666;

    label {
        display: block;
        position: relative;
        cursor: pointer;
        padding-left: calc(var(--width) + 1em);
        min-width: var(--width);
        min-height: var(--height);

        &::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            transition: 0.25s ease-in-out;
            box-sizing: border-box;
        /* Switch Background */
        &::before {
            z-index: 1;
            background-color: var(--switch-color-unchecked);
            width: var(--width);
            height: var(--height);
            border-radius: calc(var(--height) * 0.5);
            box-shadow: 0 0 0.4em rgba(0, 0, 0, 0.2);

        /* Dot */
        &::after {
            z-index: 2;
            background-color: var(--dot-color-unchecked);
            height: calc(var(--height) - (var(--border) * 2));
            width: calc(var(--height) - (var(--border) * 2));
            transform: translate(var(--border), var(--border));
            border-radius: calc(var(--height) / 2);

        &:active::after {
            width: calc(var(--height) * 1.2);
            max-width: calc(var(--height) * 2);

    input {
        width: 0;
        height: 0;
        visibility: hidden;
        display: none;

        &:checked + label {
            &::before {
                transition: 0.5s;
                background-color: var(--switch-color-checked);
            &::after {
                transform: translate(
                    calc(var(--width) - 100% - var(--border)),
                background-color: var(--dot-color-checked);

    font-size: var(--size);