WlTagsInput

Editable string tags with validation, duplicate control and form submission.
Components / Inputs v1.0.0-rc.1

Limits

Vue

Editable string tags with validation, duplicate control and form submission.

Vue
Full example
<script setup lang="ts">
import { WlButton, WlTagsInput } from "legato-ui";
import { useWlId } from "legato-ui/composables";
import { ref } from "vue";
const tags = ref(["Vue"]);
const rejected = ref("");
const helpId = `tags-example-${useWlId()}`;
</script>

<template>
  <div class="wl-stack" data-space="md" data-review-example="WlTagsInput">
    <WlTagsInput
      v-model="tags"
      aria-label="Tags"
      :aria-describedby="helpId"
      placeholder="Add a tag"
      :max="3"
      :validator="(value) => value.length >= 2"
      :invalid="!!rejected"
      
      @reject="(value) => rejected = value"
      @add="rejected = ''"
    />
    <p :id="helpId" class="wl-text-small">{{ "Editable string tags with validation, duplicate control and form submission." }}</p>
    <p v-if="rejected" role="alert">{{ "Could not add “{value}”. Check length, duplicates and the three-tag limit.".replace("{value}", () => rejected) }}</p>
    <WlButton size="sm" @click="tags = ['Vue']; rejected = ''">{{ "Restore example" }}</WlButton>
    <output aria-label="Tags">{{ tags.join(", ") }}</output>
  </div>
</template>

States

Vue

Editable string tags with validation, duplicate control and form submission.

Vue
Full example
<script setup lang="ts">
import { WlButton, WlTagsInput } from "legato-ui";
import { useWlId } from "legato-ui/composables";
import { ref } from "vue";
const tags = ref(["Vue"]);
const rejected = ref("");
const helpId = `tags-example-${useWlId()}`;
</script>

<template>
  <div class="wl-stack" data-space="md" data-review-example="WlTagsInput">
    <WlTagsInput
      v-model="tags"
      aria-label="Tags"
      :aria-describedby="helpId"
      placeholder="Add a tag"
      :max="3"
      :validator="(value) => value.length >= 2"
      :invalid="!!rejected"
      
      @reject="(value) => rejected = value"
      @add="rejected = ''"
    />
    <p :id="helpId" class="wl-text-small">{{ "Editable string tags with validation, duplicate control and form submission." }}</p>
    <p v-if="rejected" role="alert">{{ "Could not add “{value}”. Check length, duplicates and the three-tag limit.".replace("{value}", () => rejected) }}</p>
    <WlButton size="sm" @click="tags = ['Vue']; rejected = ''">{{ "Restore example" }}</WlButton>
    <output aria-label="Tags">{{ tags.join(", ") }}</output>
  </div>
</template>

Tags with validation and recovery

Editable string tags with validation, duplicate control and form submission.

Vue

Editable string tags with validation, duplicate control and form submission.

Vue
Full example
<script setup lang="ts">
import { WlButton, WlTagsInput } from "legato-ui";
import { useWlId } from "legato-ui/composables";
import { ref } from "vue";
const tags = ref(["Vue"]);
const rejected = ref("");
const helpId = `tags-example-${useWlId()}`;
</script>

<template>
  <div class="wl-stack" data-space="md" data-review-example="WlTagsInput">
    <WlTagsInput
      v-model="tags"
      
      aria-label="Tags"
      :aria-describedby="helpId"
      placeholder="Add a tag"
      :max="3"
      :validator="(value) => value.length >= 2"
      :invalid="!!rejected"
      @reject="(value) => rejected = value"
      @add="rejected = ''"
    />
    <p :id="helpId" class="wl-text-small">{{ "Editable string tags with validation, duplicate control and form submission." }}</p>
    <p v-if="rejected" role="alert">{{ "Could not add “{value}”. Check length, duplicates and the three-tag limit.".replace("{value}", () => rejected) }}</p>
    <WlButton size="sm" @click="tags = ['Vue']; rejected = ''">{{ "Restore example" }}</WlButton>
    <output aria-label="Tags">{{ tags.join(", ") }}</output>
  </div>
</template>