Open menu dropdown
MazInputTags
MazInputTags is an input to enter several values as tags and return an array of strings. Type a value and press Enter or a comma to add it, Backspace or the cross of a tag to remove it. Same sizes and states as MazInput.
Before use it, you should install the MazUi plugin in your project, follow instructions in Getting Started
Basic usage
vuenuxt
Tags: [ "vue", "nuxt" ]
vue
<script lang="ts" setup>
import MazInputTags from 'maz-ui/components/MazInputTags'
import { ref } from 'vue'
const tags = ref(['vue', 'nuxt'])
</script>
<template>
<MazInputTags
v-model="tags"
label="Technologies"
block
/>
</template>Enteror,adds the typed text, comma separated values add several tags at once. The duplicates are ignored.- The text is also added when the input loses the focus, unless
:add-tags-on-blur="false". - A first
Backspacein the empty input marks the last tag, a second one removes it. The cross of a tag removes it. - There is no floating label in the field:
labelis the placeholder of the input (unlessplaceholderis set) and its accessible name. Usetop-labelfor a visible label above the field.
Top label and assistive text
vue
Press Enter or a comma to add a technology
vue
<MazInputTags
v-model="tags"
top-label="Technologies"
placeholder="Add a technology"
assistive-text="Press Enter or a comma to add a technology"
block
/>Sizes
The sizes have the heights of MazInput: aligned in a form, a MazInputTags and a MazInput of the same size have the same height.
vuenuxt
MazInput mini
vuenuxt
MazInput xs
vuenuxt
MazInput sm
vuenuxt
MazInput md
vuenuxt
MazInput lg
vuenuxt
MazInput xl
vue
<MazInputTags v-model="tags" size="mini" label="mini" />
<MazInputTags v-model="tags" size="xs" label="xs" />
<MazInputTags v-model="tags" size="sm" label="sm" />
<MazInputTags v-model="tags" size="md" label="md" />
<MazInputTags v-model="tags" size="lg" label="lg" />
<MazInputTags v-model="tags" size="xl" label="xl" />Colors
color sets the color of the focused field and of the tags.
vuenuxt
vuenuxt
vuenuxt
vuenuxt
vuenuxt
vuenuxt
vuenuxt
vuenuxt
vue
<MazInputTags v-model="tags" color="secondary" label="secondary" />
<MazInputTags v-model="tags" color="success" label="success" />
<MazInputTags v-model="tags" color="contrast" label="contrast" />States
vuenuxt
At least 3 technologies
vuenuxt
vuenuxt
vuenuxt
vue
<MazInputTags v-model="tags" label="Error" error assistive-text="At least 3 technologies" />
<MazInputTags v-model="tags" label="Success" success />
<MazInputTags v-model="tags" label="Warning" warning />
<MazInputTags v-model="tags" label="Disabled" disabled />Rounded
vuenuxt
vue
<MazInputTags v-model="tags" label="Technologies" rounded-size="full" />The other attributes (name, autocomplete, @focus...) are passed to the <input>.
Props
| Name | Description | Type | Required | Default | Possible values |
|---|---|---|---|---|---|
| id | The id of the input | string | No | - | - |
| model-value | v-model The modelValue of the input | (string | number)[] | No | - | - |
| placeholder | The placeholder of the input | string | No | - | - |
| label | The label of the input: its accessible name, and its placeholder without placeholder | string | No | - | - |
| top-label | Static label displayed above the field | string | No | - | - |
| assistive-text | Text displayed below the field (help, error message) | string | No | - | - |
| disabled | Disable the input | boolean | No | false | - |
| error | Display the input with error style | boolean | No | false | - |
| success | Display the input with success style | boolean | No | false | - |
| warning | Display the input with warning style | boolean | No | false | - |
| size | The size of the input, the same heights as MazInput | "xs" | "sm" | "md" | "lg" | "xl" | "mini" | No | 'md' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'mini' |
| rounded-size | The rounded size of the field | MazRoundedSize | No | 'md' | - |
| color | The color of the focused field and of the tags | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent" | No | "primary" | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'destructive' | 'contrast' | 'transparent' |
| block | The input will be displayed in full width | boolean | No | - | - |
| add-tags-on-blur | Add the typed text as tags when the input is blurred | boolean | No | true | - |
| hint | The hint text displayed in place of the label | string | No | - | - |
Events
| Event name | Payload | Description |
|---|---|---|
| update:model-value | value?: (string | number)[] | undefined | The tags are added or removed |