1.0.8 • Published 6 months ago

v3-tag-input v1.0.8

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

V3TagInput

This is a simple input field for entering V3 tags. It is written in vue 3 and has no dependencies. It is totally unstyled and can be used in any project. It is highly customizable and can be used in any project.

Installation

npm install v3-tag-input

Import

import v3TagInput from "v3-tag-input";

Usage

<script setup>
import { ref } from "vue";
import v3TagInput from "v3-tag-input";
const tags = ref([]);
</script>

<template>
  <v3TagInput
    placeholder="Add Skills"
    :removeAble="true"
    :allowDuplicates="true"
    :allowEmpty="true"
    @onDuplicate="() => console.log('Duplicate!')"
    @onRemove="() => console.log('Removed!')"
    @getTags="($event) => (tags = $event)"
  />
</template>

Props

NameTypeDefaultDescription
placeholderString""Placeholder text
removeAbleBooleanfalseIf true, tags can be removed by clicking on the x
allowDuplicatesBooleanfalseIf true, duplicate tags can be added
allowEmptyBooleanfalseIf true, empty tags can be added
onDuplicateFunctionnullCallback function that is called when a duplicate tag is added
onRemoveFunctionnullCallback function that is called when a tag is removed
getTagsFunctionnullCallback function that is called when tags are changed

Events

NameDescription
onDuplicateCallback function that is called when a duplicate tag is added
onRemoveCallback function that is called when a tag is removed
getTagsCallback function that is called when tags are changed

Styling

The component is totally unstyled. You can style it by using the following classes:

/* .tagInputContainer */
.tagInputContainer {
  padding: 1rem 1rem;
  background-color: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

/* .tags */
.tags {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #333;
  background-color: #f3f4f6;
  border-radius: 9999px;
}

/* .tagRemoveIconWrap */
.tagRemoveIconWrap {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem;
  margin-left: 0.5rem;
  font-size: 0.875rem;
  color: #718096;
  background-color: transparent;
  border-radius: 9999px;
  transition: background-color 0.2s, color 0.2s;
  border: none;
}

.tagRemoveIconWrap:hover {
  background-color: #e2e8f0;
  color: #1a202c;
}

/* .tagRemoveIcon */
.tagRemoveIcon {
  width: 0.5rem;
  height: 0.5rem;
}

/* .tagInput */
.tagInput {
  outline: none;
  height: 100%;
  width: auto;
  border: none;
}