Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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.


Auto Save

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.


                <label class="switch">
  <input type="checkbox" id="theme-switcher">
  <span class="slider round"></span>


                /* Light Theme */
:root {
  --bg-color: #ffffff;
  --text-color: #000000;
  /* Add more as needed */

/* Dark Theme */
body.dark {
  --bg-color: #000000;
  --text-color: #ffffff;

body {
  background-color: var(--bg-color);
  color: var(--text-color);


.switch {
    position: relative;
    display: inline-block;
    width: 44px; // Smaller width
    height: 24px; // Smaller height

    input {
        opacity: 0;
        width: 0;
        height: 0;

        &:checked + .slider {
            background-color: #476173;

            &:before {
                transform: translateX(20px);
                background-color: transparent;
                border-radius: 50%;
                border-top-color: transparent;
                border-left-color: transparent;
                border-right-color: transparent;
                box-shadow: inset -5px -3px 0 #d8e9ef;

    .slider {
        position: absolute;
        cursor: pointer;
        top: 0; left: 0; right: 0; bottom: 0;
        background-color: #7bb9f5;
        transition: .4s;
        border-radius: 20px;
        box-shadow: 0 0 0.25em  rgba(67,71,85,0.27), 0.2px 0.2em 24px 0 rgba(1,29,77,0.15);

        &:before {
            position: absolute;
            content: '';
            height: 16px;
            width: 16px;
            left: 4px;
            bottom: 4px;
            background-color: yellow;
            transition: .4s;
            border-radius: 50%;
            text-align: center;
            line-height: 16px;

/*Switcher demo styles*/
  display: grid;
  min-height: 100vh;
  padding: 0;
  margin: 0;
  place-items: center;


                document.addEventListener('DOMContentLoaded', function() {
  const themeSwitcher = document.getElementById('theme-switcher');

  // Load saved theme preference
  const savedTheme = localStorage.getItem('theme');
  if (savedTheme === 'dark') {
    themeSwitcher.checked = true;

  // Detect OS preference if no saved preference
  else if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
    themeSwitcher.checked = true;

  // Handle toggle switch
  themeSwitcher.addEventListener('change', function() {
    localStorage.setItem('theme', this.checked ? 'dark' : 'light');