JSFiddle - React, Tailwind, and code Playground

by Olga Filipova

HTML

<script src="https://vuejs.org/js/vue.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div id="app" class="container">
  <h2>{{ title }}</h2>
  <div class="input-group">
    <input v-model="newItem" @keyup.enter="addItem" placeholder="add shopping list item" type="text"
           class="form-control">
  <span class="input-group-btn">
    <button @click="addItem" class="btn btn-default" type="button">Add!</button>
  </span>
  </div>
  <ul>
    <li v-for="item in items" :class="{ 'removed': item.checked }">
      <div class="checkbox">
        <label>
          <input type="checkbox" v-model="item.checked"> {{ item.text }}
        </label>
      </div>
    </li>
  </ul>
  <div class="footer">
    <hr/>
    <em>Change the title of your shopping list here</em>
    <input v-model="title"/>
  </div>
</div>

CSS

.container {
  width: 40%;
  margin: 20px auto 0px auto;
}

.removed label {
  text-decoration: line-through;
}

ul li {
  list-style-type: none;
}

ul li span {
  margin-left: 5px;
}

.footer {
  font-size: 0.7em;
  margin-top: 20vh;
}

JavaScript

var data = {
  items: [{ text: 'Bananas', checked: true }, { text: 'Apples', checked: false }],
  title: 'My Shopping List'
};

new Vue({
  el: '#app',
  data: data,
  methods: {
    addItem: function () {
      var text;

      text = this.newItem.trim();
      if (text) {
        this.items.push({
          text: text,
          checked: false
        });
        this.newItem = '';
      }
    }
  }
});