JSFiddle - React, Tailwind, and code Playground

by aljordan82

HTML

<link rel="stylesheet" href="http://select2.github.io/select2/select2-3.5.2/select2.css">
<script src="http://select2.github.io/select2/select2-3.5.2/select2.js"></script>
<p><input type="hidden" class="select2field" /></p>

CSS

p { margin-bottom: .5em; }

JavaScript

$('.select2field').select2({
    tags: true,
    createSearchChoice: function (term, data) {
        if ($(data).filter(function () {
            return this.text.localeCompare(term) === 0;
        }).length === 0) {
            return {
                id: term,
                text: term
            };
        }
    },
                tokenSeparators: [';'],

  selectOnBlur:true,
    width: '300px',
    data: [
        {id: 0, text: 'story'},
        {id: 1, text: 'bug'},
        {id: 2, text: 'task'}
    ]
});