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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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


                <body class="theme theme--dark" data-theme="dark">
<div class="wrapper">
   <button class="theme-toggle" data-theme="dark">Переключить тему</button>
<div class="wrapper">

  <h1>Это сайт</h1>
  <p>А это текст на нем</p>
  <p>По умолчанию пропишем стили для темной темы</p>
  <p>Все цвета на сайте укажем через кастомные свойства CSS</p>
  <p>А потом будем только переопределять эти переменные.</p>
  <p>По нажатию на кнопку будем менять data-theme</p>



                   @import url('');

    * {
      box-sizing: inherit;

    :root {
      --bg: #333;
      --color: #eee;

    html {
      box-sizing: border-box;

    body {
      margin: 0;
      font-size: 20px;
      font-family: 'Neucha', cursive;
      background-color: var(--bg);
      color: var(--color);

    [data-theme="dark"] {


    [data-theme="light"] {
      --bg: #eee;
      --color: #333;

    .wrapper {
      width: 80%;
      margin: 20px auto;

    h1 {
      font-weight: 400;


                const body = document.body;
let btnToggle = document.querySelector('.theme-toggle');
btnToggle.addEventListener('click', () => {

// установим тему из localStorage, если там есть запись
const setTheme = () => {
  let currentTheme = localStorage.getItem('theme');
  if (currentTheme) {
    body.dataset.theme = currentTheme;

// переключение темы по кнопке
const toggleTheme = () => {

  if (body.dataset.theme === 'dark') {
    body.dataset.theme = 'light';

  } else if (body.dataset.theme === 'light') {
    body.dataset.theme = 'dark';

  localStorage.setItem('theme', body.dataset.theme);