css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

<template id="tagsInput-template">
	<div class="tags">
		<span class="asInput" v-for="(tag, index) in tags1" :class="{ deleting: confirmWaiting && position==index+1 }">{{tag}}</span>
		<input v-model="newTag" placeholder="Add" @keyup.enter="add()" @keyup.backspace="checkIfRemove()" @keyup.left="left()" @keyup.right="right()" :readonly="readonly"/>
		<span class="asInput" v-for="(tag, index) in tags2">{{tag}}</span>

<div id="app">
	<!--<div class="my-control"
         v-for="input in inputs"
         :class="{active: input.isActive}">
    <div class="form-label" 
         :class="{active: input.isActive || input.value}">
	<h1>Very simple tags-input with VueJS 2</h1>
	<tags-input :tags="tags" :readonly="readonly"></tags-input>
		<input type="checkbox" v-model="readonly" /> Readonly
		<li>Write and press enter to add a new tag.</li>
		<li>Press left (it needs to be at position 0 in the input value) or right key (it needs to be at last position in the input value) in order to change position of the input in the list.</li>
		<li>Press backspace twice (within a second and a half) aimed at deleting previous tag.</li>
.tags {
	display: flex;
	flex-direction: row;
	flex-shrink: 0;
	.asInput {
		width: auto;
		padding-right: 1rem;
		background: rgba($cyan, 0.2);
		margin: 0 .2rem;
		&.deleting {
			background: $red;
	input {
		margin: 0 .2rem;
		max-width: 15rem;
		opacity: 1;
		transition: all .3s ease-in-out;
	input[readonly] {
		max-width: 0;
		padding-left: 0;
		padding-right: 0;
		opacity: 0;
		margin-left: 0;
		margin-right: 0;
		pointer-events: none;

label {
	margin: 1rem 0;

#app {
	padding: 2rem;
	h1 {
		margin-bottom: 1rem;
              Vue.config.keyCodes.backspace = 8

var tagsInput = Vue.component('tagsInput', Vue.extend({
	template: '#tagsInput-template',
	props: ['tags', 'readonly'],
			newTag: '',
			confirmWaiting: false,
			position: 1
	computed: {
		tags1: function() {
			return this.tags.slice(0, this.position)
		tags2: function() {
			return this.tags.slice(this.position, this.tags.length)
	methods: {
		add() {
			this.tags.splice(this.position, 0, this.newTag)
			this.position += 1
			this.newTag = ''
		checkIfRemove() {
			if(this.confirmWaiting) {
				if(this.newTag.length===0) {
					this.tags.splice(this.position-1, 1)
					this.position -= 1
					this.confirmWaiting = false
			} else {
				//this.confirmWaiting = true
				var _this = this
				this.confirmWaiting = setTimeout(function(){
					_this.confirmWaiting = false;
				}, 1500)
		left() {
			var pos = event.target.selectionStart;
			if(pos===0) {
				this.position = Math.max(0, this.position-1);
			var evt = event
			setTimeout(function() {
			}, 1300)
		right() {
			var pos = event.target.selectionStart;
			if(pos===this.newTag.length) {
				this.position = Math.min(this.tags.length, this.position+1);
			var evt = event
			setTimeout(function() {
			}, 200)

var app = new Vue({
			tags: ['Aurora', 'Hannah', 'John', 'Simone'],
			readonly: false
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................