Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="theme-switch-wrapper">
    <label class="theme-switch" for="checkbox">
        <input type="checkbox" id="checkbox" />
        <div class="slider round"></div>
  </label>
  <em>Enable Dark Mode!</em>
</div>
<h1>Dangerous Game</h1>
<p>Once upon a time, i just saw you. I have beautiful memory about us. Of course that's just in my dream.</p>
<p>Little did you know i was dying to the very end. You killed me with every smiles you gave. My heart melted and my knees shook. I always want more than that.</p>
<p>But i guess it wasn't meant to be. But you'll never truly know how much you meant to me. You're always there, and wiped away every tears.</p>
<p>I'm just your nothing. I know he's your everything. When i saw you looking at his eyes, i realized of who i am. The tiny drops of rain, symbolizez my tears and pain. Losing you is my biggest fear. Now everything is clear.</p>
<p>I have been a rebel all my life. Fighting against established formality. Dreaming about adventures and another shit. Making plans inside my own mind. Trying to break free to be myself. Looking far that magic knife. To cut the bridge that holds me.</p>
<p>Loving you was never wrong. Indeed it made me strong. I was once a <a href="https://www.vocabulary.com/dictionary/rebel">rebel</a>. But you turned me to an angel. Or at least that's what i think.</p>
<p>I just wish you would've waited, stay there. I still dream about you in this one-sided love. It's hard to breathe without you. I wish you loved me the way i loved you.</p>
<p>But i realize that this is a lesson to me. To understand the truth. This one-sided love feels like a dangerous game. But again, thats the name of the game.</p>

<p>— abay</p>
              
            
!

CSS

              
                :root {
    --primary-color: #302AE6;
    --secondary-color: #536390;
    --font-color: #424242;
    --bg-color: #fff;
    --heading-color: #292922;
}
body {
	background-color: var(--bg-color);
	color: var(--font-color);
	margin-top: 1.5em;
	margin-left: 2em;
	max-width: 40em;
	font-family: monospace;
	line-height: 1.5;
}
[data-theme="dark"] {
    --primary-color: #9A97F3;
    --secondary-color: #818cab;
    --font-color: #e1e1ff;
    --bg-color: #161625;
    --heading-color: #818cab;
}
h1 {
	margin-bottom: 0px;
	color: var(--secondary-color);
}
a {
	color: var(--primary-color);
}
.theme-switch-wrapper {
	display: flex;
	margin-top: 1.5em;
	/*margin-left: 2em;*/
}
em {
	margin-top: 0.5em;
	margin-left: 1em;
	font-size: 1rem;
}
.theme-switch {
  display: inline-block;
  height: 34px;
  position: relative;
  width: 60px;
}

.theme-switch input {
  display:none;
}

.slider {
  background-color: #ccc;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
}

.slider:before {
  background-color: #fff;
  bottom: 4px;
  content: "";
  height: 26px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 26px;
}

input:checked + .slider {
  background-color: #66bb6a;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}
              
            
!

JS

              
                window.console = window.console || function(t) {};
if (document.location.search.match(/type=embed/gi)) {
  window.parent.postMessage("resize", "*");
}
console.log('Ka.');
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');

function switchTheme(e) {
    if (e.target.checked) {
        document.documentElement.setAttribute('data-theme', 'dark');
        localStorage.setItem('theme', 'dark'); //add this
    }
    else {
        document.documentElement.setAttribute('data-theme', 'light');
    }    
}
toggleSwitch.addEventListener('change', switchTheme, false);

const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
    document.documentElement.setAttribute('data-theme', currentTheme);

    if (currentTheme === 'dark') {
        toggleSwitch.checked = true;
    }
}
              
            
!
999px

Console