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

              
                <script>
  let holidayForm = function() {
  return {
    holidays: [
      {id: 'newyears', name: 'New Year', date: 'Jan 1'},
      {id: 'aprilfools', name: "April Fool's Day", date: 'Apr 1'},
      {id: 'juneteenth', name: 'Juneteenth', date: 'June 19'}
    ],
    selectedHolidays: [],
    toggleHoliday(id) {
      if (this.holidaySelected(id)) {
        this.selectedHolidays = this.selectedHolidays.filter(h => h !== id)
      } else {
        this.selectedHolidays.push(id)
      }

      this.$nextTick(() => console.log(this.$el.querySelector('input[name=selectedHolidays]').value))
    },
    holidaySelected(id) {
      return this.selectedHolidays.indexOf(id) > -1;
    }
  }
}
</script>


<form x-data="holidayForm()" class="block p-10">
  <label class="block text-xl">Your favorite holiday(s):</label>
  <div class="space-y-6">
    <template x-for="holiday in holidays">
      <div @click="toggleHoliday(holiday.id)" class="flex items-center">
        <div class="w-8 h-8 mr-3 border-2 border-gray-800">
          <svg x-cloak x-show="holidaySelected(holiday.id)" 
               viewBox="0 0 148 185" 
               xmlns="http://www.w3.org/2000/svg" 
               fill-rule="evenodd" 
               clip-rule="evenodd" 
               stroke-linejoin="round" 
               stroke-miterlimit="2">
            <path d="M42.24 153.673c-.736-3.425-1.52-6.861-2.499-10.287-3.75-13.125-6.336-27.497-12.973-39.665-3.552-6.512-8.024-12.371-12.112-18.503a8.004 8.004 0 00-11.094-2.219 8.004 8.004 0 00-2.219 11.094c3.827 5.739 8.054 11.195 11.378 17.29 6.077 11.141 8.202 24.38 11.636 36.398 2.057 7.201 3.213 14.454 4.958 21.53.504 2.045 1.184 4.177 1.684 6.177.36 1.441 1.393 4.234 1.393 4.234a8 8 0 0015.021-.129s1.324-3.808 2.285-5.57c2.202-4.036 4.402-7.991 6.368-12.169 6.24-13.258 13.433-25.884 20.896-38.478 21.532-36.336 37.88-79.472 68.126-109.719a8.004 8.004 0 000-11.314 8.003 8.003 0 00-11.313 0c-31.179 31.178-48.382 75.422-70.577 112.876-7.465 12.597-14.658 25.233-20.958 38.454z"/>
          </svg>
        </div>
        <div>
          <div class="font-bold" x-text="holiday.name"></div>
          <span class="block text-sm" x-text="holiday.date"></span>
        </div>
      </div>
    </template>
    <input x-model="selectedHolidays" type="hidden" name="selectedHolidays">
  </div>
</form>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console