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 is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                // Center the dropdown vertically and horizontally using bootstrap flex utilities
// Scroll to the bottom inside this pane to see the array of items
    // The entry point for our Vue app
        // Notice how we have bound text to the selected value
        b-dropdown#ddown1.m-md-2(:text='selectedText', variant='warning', size='lg')
          // Add some padding to space out the form nicely inside the dropdown
            // Notice how our v-model is linked directly with the searchTerm property in the Vue instance
  'text', placeholder='Search', v-model='searchTerm')
  'outline-none', type='submit', @click.prevent='clearSearch')
          // Loop through the filtered items and if clicked select the item and clear the search
'i in filteredItems', :key='i', @click='select(i)')
            b-form-checkbox(:value='i', :key='i', v-model='selected')
              | {{split(i, searchTerm)['prefix']}}
              b {{split(i, searchTerm)['term']}}
              | {{split(i, searchTerm)['suffix']}}
          // If we have no search results display this item inside the dropdown
          b-dropdown-header(v-if='filteredItems.length === 0')
            | No results for "
            b {{searchTerm}}
            | "
      p.px-5 You selected {{selected.join(" ") || "nothing"}}



                html {
  height: 100%;

/* Make the dropdown scroll within a fixed height instead of taking all the screen */
.dropdown-menu {
  height: 256px;
  overflow-y: scroll;
  padding-top: 0;

/* Fix the search bar at the top inside the dropdown */
.dropdown-menu form {
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;

/* Place the button inside the text box */
.dropdown-menu form .btn {
  position: absolute;
  right: 0;

#app p {
  position: absolute;
  left: 0;
  bottom: 0;

/* Hide vue syntax while loading */
[v-cloak] {
  display: none;



new Vue({
  el: '#app',
  data() {
    return {
      // The search term entered by the user
      searchTerm: '',
      items: rawItems,
      selectedText: 'Expand Me',
      selected: []
  computed: {
    filteredItems() {
      const filtered =  this.items
      .sort((a, b) => {
        let indexOfA = this.selected.indexOf(a)
        let indexOfB = this.selected.indexOf(b)
        if(indexOfA === -1 && indexOfB === -1) {
          return a.localeCompare(b);
        else if(indexOfB > -1 && indexOfA > -1){
          return a.localeCompare(b)
        else {
          return indexOfB - indexOfA
      .filter(i => {
        if(this.searchTerm === '') {
          return this.items
        // Compare everything after converting to lower case
        let lowerI = i.toLowerCase()
        let lowerS = this.searchTerm.toLowerCase()
        // If they are equal of if the item starts with the search term of the item ends with the search term
        return lowerI === lowerS || lowerI.startsWith(lowerS) || lowerI.endsWith(lowerS) || lowerI.includes(lowerS) || lowerS.includes(lowerI)
      return filtered;
    getSelectedText() {
      if(!this.selected) {
        return 'Expand Me'
      else if(this.selected.length === 1) {
        return this.selected[0]
      else {
        return this.selected.length + ' pairs selected'
  methods: {
    Called when the user clicks an item to select it
    Update the selected value and clear the search bar
    select(value) {
      this.selectedText = "Expand Me";
      const position = this.selected.indexOf(value)
      if(position >= 0) {
        this.selected.splice(position, 1)
      else {
    split (str, search) {
      let strL = str.toLowerCase()
      let srL = search.toLowerCase()
      return {
        prefix: strL.substr(0, strL.indexOf(srL)).toUpperCase(), 
        term: srL.toUpperCase(), 
        suffix: strL.substr(strL.indexOf(srL) + srL.length, strL.length).toUpperCase()
    clearSearch() {
      this.searchTerm = ''
  watch: {
    selected(newValue, oldValue) {
      if(newValue.length === 0) {
        this.selectedText = 'Expand Me'
      else if(newValue.length === 1) {
        this.selectedText = newValue[0];
      else {
        this.selectedText = newValue.length + ' items selected'