JSFiddle - React, Tailwind, and code Playground

by Bertalan Eck

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>
<div class="ui form" id="app">
  <div class="field" >
  <label>Tags</label>
  <input type="text" name="" placeholder="Add new tag" v-on:keyup.enter="addNewTag" v-model="newTagTest">
  <div style="display: inline-block; padding-top: 10px;">
    <ui-tag v-for="(item, index) in tags"
             v-bind:title="item.title"
             v-bind:key="item.id"
             v-on:remove="tags.splice(index, 1)">
    </ui-tag>
  </div>
 </div>
</div>

CSS

#app {
  padding-left: 10px;
}

JavaScript

Vue.component('ui-tag', {
  template: '<a class="ui blue tag label">{{ title }} <i class="delete icon" v-on:click="deleteTag"></i></a>',
  props: ['title'],
  methods: {
      deleteTag: function () {
        this.$emit('remove')
      }
  }
})

new Vue({
	el: '#app',
  data: function () {
      return {
        tags: [],
        newTagTest: '',
        nextTagId: 1
      }
    },
    methods: {
      addNewTag: function () {
        this.tags.push({
          id: this.nextTagId,
          title: this.newTagTest
        })
        this.nextTagId++
        this.newTagTest = ''
      }
    }
})