WlTagsInput

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

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

placeholder

Hint shown when the control has no displayed text.

name

Name used by the component's native form controls.

max

Maximum number of tag values accepted in the model.

Allow repeated tag values in the model.

Disable user interaction with this component.

Keep the current value readable while preventing user edits.

Expose a validation error state on the control.

Indicate pending work supplied by the application.

Props separators, validator, variant, size, density, pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Vue

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

Vue
Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<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
Vue SFC · additional 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>