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.


  <figure class="post-card">
<!--     <img src="" /> -->
    <figcaption>The Coldest Sunset</figcaption>
    <p class="text-gray-700 text-base">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus quia, nulla! Maiores et perferendis eaque, exercitationem praesentium nihil.
  <div class="user-toggle">
    <div role="status"></div>
    <button class="toggle-btn">
      <span class="toggle-btn__mode">dark</span>


                :root {
  --color-mode: 'light';
  --color-light: rgba(0, 0, 0, .75);
  --color-dark: rgba(255, 255, 255, .75);
  --background-light: #f0f2f4;
  --background-dark: #242424;
  --border-light: rgba(0, 0, 0, .33);
  --border-dark: rgba(255, 255, 255, .33);

[data-user-color-scheme='light'] {
  --text-color: var(--color-light);
  --background-color: var(--background-light);
  --border-color: var(--border-light);

[data-user-color-scheme='dark'] {
  --text-color: var(--color-dark);
  --background-color: var(--background-dark);
  --border-color: var(--border-dark);

body {
  padding: 2rem 1rem;
  color: var(--text-color);
  background: var(--background-color);

main {
  width: 100%;
  figure {
    margin: 0 auto;
    max-width: 30rem;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 30px;
    figcaption {
      font-weight: bold;
      font-size: 2rem;
      margin-bottom: 16px;
    p {
      color: var(--text-color);
  .user-toggle {
    text-align: center;
    button {
      padding: 8px 12px;
      font-size: 1.25rem;



                const APP_THEME = 'user-color-scheme'

const toggleButton = document.querySelector('.toggle-btn')
const toggleButtonMode = document.querySelector('.toggle-btn__mode')

const initTheme = () => {
  if (window.matchMedia) {
    const colorSchema  = window.matchMedia('(prefers-color-scheme: dark)')
    console.log(colorSchema.matches) // Boolean: true/false
    // set init theme mode as dark
    localStorage.setItem(APP_THEME, colorSchema.matches ? 'dark' : 'light')
    toggleButtonMode.innerHTML = colorSchema.matches ? 'light' : 'dark'

 * if user select the theme, then use the given theme
const applyTheme = givenTheme => {
  let currentTheme = givenTheme || localStorage.getItem(APP_THEME)
  if(currentTheme) {
    document.body.setAttribute('data-user-color-scheme', currentTheme)

 * get the persistent theme mode, toggle it, then store it.
const toggleTheme = () => {
  let currentTheme = localStorage.getItem(APP_THEME)
  switch(currentTheme) {
    case 'light':
      currentTheme = 'dark'
      toggleButtonMode.innerHTML = 'light'
    case 'dark':
      currentTheme = 'light'
      toggleButtonMode.innerHTML = 'dark'

  localStorage.setItem(APP_THEME, currentTheme)
  return currentTheme

toggleButton.addEventListener('click', e => {