vue-tag-selector
<p align="center"> <img alt="vue-tag-selector logo" src="https://raw.githubusercontent.com/tomquinonero/vue-tag-selector/master/docs/tag-selector-logo.png"> <br/> <br/> <a href="https://github.com/tomquinonero/vue-tag-selector"><img src="https://img.shi
Last updated a month ago by tomquinonero .
Original npm · Tarball · package.json
$ cnpm install vue-tag-selector 
SYNC missed versions from official npm registry.

vue-tag-selector logo

npm bundle size (minified) npm bundle size (minified + gzip) npm version

Vue-tag-selector is a component for vuejs for tag type fields.
Light (6.3kb gzipped) and customizable.
Offering regex validation.

vue-tag-selector demo

Check out the demo

Installation

# with npm
npm install --save vue-tag-selector
# with yarn
yarn add vue-tag-selector

Usage

For using the component you just need to import the component and register it:

import TagSelector from 'vue-tag-selector'
export default {
  components: { TagSelector },
  data(){
    return {
      tags: []
    }
  }
}

And then use it in your template:

<template>
  <div class="container">
    <tag-selector name="tags" v-model="tags"/>
  </div>
</template>

API Documentation

Here's a list of the props available:

  • label: Displays a label, has to be String can be ignored
  • name: Required. usually the field name.
  • classes: Allows you to add classes to the field. String or Array.
  • regex: A RegExp. Validates every tag and disallow adding if not matching. By default it's alphanumerical only (/^[a-zA-Z0-9]*$/)
  • regexError: The error displayed when the Regex doesn't match

Style

The component philosophy is pretty straightforward here: only the mandatory style is bundled. I personally never liked js library that needs too much CSS. Only 26 lines of CSS here ????. But you can easily stylize the component.

Have an example template:

<div class="field tag-selector">
  <label for="tags">Post tags</label>
  <div class="tag-selector--input">
      <div class="tag-selector--item">
        Dogs <i class="icon tag-selector--remove">delete_icon</i>
      </div>
      <div class="tag-selector--item">
        Cats <i class="icon tag-selector--remove">delete_icon</i>
      </div>
      <div class="tag-selector--item">
        Horses <i class="icon tag-selector--remove">delete_icon</i>
      </div>
    <input type="text" id="tags" name="tags" class="tag-selector-input">
  </div>
  <p class="validation-message">The tag you entered is at the wrong format. Please only use alphanumerical characters.</p>
</div>

One rule tho, .tag-selector--input has to be display: flex;.

You can see different themes applied in the demo

Related

on Bundlephobia - on npm

Created by Tom Quinonero

Current Tags

  • 0.2.4                                ...           latest (a month ago)

10 Versions

  • 0.2.4                                ...           a month ago
  • 0.2.3                                ...           a month ago
  • 0.2.2                                ...           a month ago
  • 0.2.1                                ...           a month ago
  • 0.2.0                                ...           a month ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 10
This Month 10
Last Day 0
Last Week 0
Last Month 87
Dependencies (1)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2018 © taobao.org |