Git Product home page Git Product logo

vue-tags's Introduction

Vue-Tags

A Flexible Vue.js 2 input Tag component where you can edit wathever you like related to HTML/CSS.

Installation :

npm install vue-tags

Getting Started

In your script entry point:

<div id="app">

  <input-tags v-model="tags">
    <div class="tags-input"
            slot-scope="{tag,removeTag,inputEventHandlers,inputBindings }">
            <span v-for="tag in tags"
              class="tags-input-tag">
              <span>{{ tag }}</span>
              <button type="button" class="tags-input-remove"
                v-on:click="removeTag(tag)"
              >&times;
             </button>
            </span>
            <input
              class="tags-input-text"  placeholder="Add tag..."
              v-on="inputEventHandlers"
              v-bind="inputBindings"
            >
          </div>
   </input-tags>

</div>

window.Vue = require("vue");

import VueTags from "vue-tags";

//Vue.component("input-tags", VueTags); If you want a global Component

const app = new Vue({
  el: "#app",
  components: {
    VueTags
  },
  data: {
    tags: ['Laravel','Vuejs'],
  }
});

Usage

Just add the tags as a v-model and follow the code above just don't change the vuejs attributes and the others is your choice do wathever you want with them.

Props

By Default The tag is added when you click the Enter Key but you can customize it by adding addKey prop with array of KeyCodes of your choice. You can have it here. For Example ['188','13'] for Comma , and Enter Key

<div id="app">

  <input-tags v-model="tags" add-key="['188','13']">
    <div class="tags-input"
            slot-scope="{tag,removeTag,inputEventHandlers,inputBindings }">
            <span v-for="tag in tags"
              class="tags-input-tag">
              <span>{{ tag }}</span>
              <button type="button" class="tags-input-remove"
                v-on:click="removeTag(tag)"
              >&times;
             </button>
            </span>
            <input
              class="tags-input-text"  placeholder="Add tag..."
              v-on="inputEventHandlers"
              v-bind="inputBindings"
            >
          </div>
   </input-tags>

</div>

const app = new Vue({
  el: "#app",
  components: {
    VueTags
  },
  data: {
    tags: ['Laravel','Vuejs'],
  }
});

By Default The tag is deleted when you click delete Key but you can customize it by adding deleteKey prop with array of KeyCodes of your choice. You can have it here. For Example ['13'] for Enter key Now When we click Enter we delete the tag

<div id="app">

  <input-tags v-model="tags" delete-key="['13']">
    <div class="tags-input"
            slot-scope="{tag,removeTag,inputEventHandlers,inputBindings }">
            <span v-for="tag in tags"
              class="tags-input-tag">
              <span>{{ tag }}</span>
              <button type="button" class="tags-input-remove"
                v-on:click="removeTag(tag)"
              >&times;
             </button>
            </span>
            <input
              class="tags-input-text"  placeholder="Add tag..."
              v-on="inputEventHandlers"
              v-bind="inputBindings"
            >
          </div>
   </input-tags>

</div>

const app = new Vue({
  el: "#app",
  components: {
    VueTags
  },
  data: {
    tags: ['Laravel','Vuejs'],
  }
});

Contributing

You are more than welcome to contribute to this repo with anything you think is useful. fixes are more than welcome.

vue-tags's People

Contributors

simoebenhida avatar dependabot[bot] avatar soub4i avatar

Stargazers

 avatar Duy. Dinh Bao avatar  avatar  avatar  avatar fairy avatar  avatar James Kingsley avatar Mostafa Kamal avatar Michael Santillán avatar  avatar

Watchers

James Cloos avatar  avatar

vue-tags's Issues

Issue with styles

Hello, is there a custom style file I suppose to link to? The inputted tags are not placed inside the text field as seen in the demo

Multiple add key

How about adding multiple add keys. Example using enter or comma add-key="13|188" . Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.