npm.io
0.0.6 • Published 5 years ago

simple-tag-editor

Licence
ISC
Version
0.0.6
Deps
0
Size
7 kB
Vulns
0
Weekly
0

simple-tag-editor

Import the lib

import { TagEditor } from "simple-tag-editor";

Import the Style

import "simple-tag-editor/index.css";

Add a reference to the input

const inputEl = document.getElementById('inputEL');

Add a custom html for the close btn

const el = '<i class="fa fa-times"></i>';

Initialize

const tagEdit = new TagEditor('tagEdit', inputEl, el);

if(inputEl) { inputEl.addEventListener('keyup', event => { if (event.keyCode === 13) { tagEdit.addTag(inputEl.value); inputEl.value = ''; } }); }

Thanks and PR's are always welcome!

Keywords