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.


    <div class="mode">
      <p class="text-mode">Light Mode</p>
      <i class="fas fa-sun"></i>
    <div class="toggle-container">
      <label class="switch">
        <input type="checkbox" />
        <span class="slider"></span>



                :root {
  --background: #fff;
  --mode-background: #f1f3f8;
  --mode-text: #0278ae;

[data-theme="dark"] {
  --background: #333;
  --mode-background: rgba(2, 120, 174,.8);
  --mode-text: #fff;

*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;

html {
  font-size: 62.5%;

body {
  font-family: sans-serif;
  height: 100vh;
  background-color: var(--background);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='' width='152' height='152' viewBox='0 0 152 152'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='temple' fill='%2328adba' fill-opacity='0.4'%3E%3Cpath d='M152 150v2H0v-2h28v-8H8v-20H0v-2h8V80h42v20h20v42H30v8h90v-8H80v-42h20V80h42v40h8V30h-8v40h-42V50H80V8h40V0h2v8h20v20h8V0h2v150zm-2 0v-28h-8v20h-20v8h28zM82 30v18h18V30H82zm20 18h20v20h18V30h-20V10H82v18h20v20zm0 2v18h18V50h-18zm20-22h18V10h-18v18zm-54 92v-18H50v18h18zm-20-18H28V82H10v38h20v20h38v-18H48v-20zm0-2V82H30v18h18zm-20 22H10v18h18v-18zm54 0v18h38v-20h20V82h-18v20h-20v20H82zm18-20H82v18h18v-18zm2-2h18V82h-18v18zm20 40v-18h18v18h-18zM30 0h-2v8H8v20H0v2h8v40h42V50h20V8H30V0zm20 48h18V30H50v18zm18-20H48v20H28v20H10V30h20V10h38v18zM30 50h18v18H30V50zm-2-40H10v18h18V10z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  display: flex;
  justify-content: center;
  align-items: center;

.mode {
  display: flex;
  margin-right: 2rem;
  font-size: 2.5rem;
  padding: 1rem;
  border: 2px solid #0278ae;
  background-color: var(--mode-background);
  color: var(--mode-text);
  border-radius: 3px;

.text-mode {
  margin-right: 1rem;

.toggle-container {
  width: 10rem;
  height: 10rem;
  display: flex;
  justify-content: center;
  align-items: center;

.switch {
  width: 15rem;
  height: 5rem;
  border-radius: 2.5rem;
  display: inline-block;
  position: relative;

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

.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid #0278ae;
  background-color: #f1f3f8;
  border-radius: 3rem;
  cursor: pointer;
  transition: all 1s;
.slider::before {
  content: "";
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 5%;
  transform: translateY(-50%);
  display: inline-block;
  background-color: #f1f3f8;
  border: 2px solid #0278ae;
  transition: all 1s;

input:checked + .slider {
  background-color: #0278ae;
  border: 2px solid #0278ae;

input:checked + .slider::before {
  transform: translate(5rem, -50%);



                const toggleMode = document.querySelector("input[type='checkbox']");
const modeSwitch = document.querySelector(".mode");

function changeTheme(event) {
  if ( {
    document.documentElement.setAttribute("data-theme", "dark");
    modeSwitch.children[0].textContent = "Dark Mode";
    modeSwitch.children[1].classList.replace("fa-sun", "fa-moon");
  } else {
    document.documentElement.setAttribute("data-theme", "light");
    modeSwitch.children[0].textContent = "Light Mode";
    modeSwitch.children[1].classList.replace("fa-moon", "fa-sun");

toggleMode.addEventListener("change", changeTheme);