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 id="app">
  <accordion>
    <accordion-item>
      <accordion-header>
        Section 1
      </accordion-header>
      <accordion-panel>
        Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
      </accordion-panel>
    </accordion-item>
    <accordion-item>
      <accordion-header>
        Section 2
      </accordion-header>
      <accordion-panel>
        Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna.
      </accordion-panel>
    </accordion-item>
    <accordion-item>
      <accordion-header>
        Section 3
      </accordion-header>
      <accordion-panel>
        Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
        <ul>
          <li>List item one</li>
          <li>List item two</li>
          <li>List item three</li>
        </ul>
      </accordion-panel>
    </accordion-item>
  </accordion>
</div>
              
            
!

CSS

              
                body {
  height: 100vh;
  padding: 2rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  background-color: #eff2f7;
  font-size: 16px;
}

#app {
  max-width: 30rem;
  margin: 0 auto;
}

.accordion-item {
  margin-bottom: 1rem;
  border-radius: 4px;
  background-color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.accordion-header {
  margin: 0;
  padding: 1rem;
  line-height: 0;
}

.accordion-header button {
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background-color: transparent;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.accordion-panel {
  display: none;
}

.accordion-panel.expanded {
  display: block;
  padding: 1rem;
  border-top: 1px solid #eee;
}
              
            
!

JS

              
                Vue.component('accordion', {
  render (createElement) {
    return createElement(
      'div', 
      { class: 'accordion' }, 
      this.$slots.default
    )
  }
})

Vue.component('accordion-item', {
  data () {
    return {
      sharedState: {
        expanded: false
      }
    }
  },
  
  provide () {
    return {
      accordionItemState: this.sharedState
    }
  },
  
  render (createElement) {
    return createElement(
      'div', 
      { class: 'accordion-item' }, 
      this.$slots.default
    )
  }
})

Vue.component('accordion-header', {
  inject: ['accordionItemState'],
  
  template: `
    <h2 class="accordion-header">
      <button @click="accordionItemState.expanded = !accordionItemState.expanded">
        {{ accordionItemState.expanded ? '▼' : '►' }} 
        <slot></slot>
      </button>
    </h2>
  `
})

Vue.component('accordion-panel', {
  inject: ['accordionItemState'],
  
  template: `
    <div class="accordion-panel" :class="{ expanded: accordionItemState.expanded }">
      <slot></slot>
    </div>
  `
})

const app = new Vue({
  el: '#app'
})
              
            
!
999px

Console