Vitral 0.2
Misc

Tag

A short label for a status or a category, in every severity, with an optional remove button.

Import

main.ts
import { Tag } from '@vitral/vue';

Severities

primarysecondarysuccessinfowarndangerhelpcontrast
<script setup lang="ts">import { Tag } from '@vitral/vue'; const severities = ['primary', 'secondary', 'success', 'info', 'warn', 'danger', 'help', 'contrast'] as const;</script> <template>    <Tag v-for="s in severities" :key="s" :value="s" :severity="s" /></template>

Icons and shape

NewVerifiedDue todayBlocked
<script setup lang="ts">import { Tag } from '@vitral/vue';</script> <template>    <Tag value="New" icon="star" />    <Tag value="Verified" icon="check" severity="success" rounded />    <Tag value="Due today" icon="clock" severity="warn" rounded />    <Tag value="Blocked" icon="error" severity="danger" /></template>

Removable

Tab to a remove button and press Delete.

vuetypescriptdesign-tokensaccessibilitylayout
<script setup lang="ts">import { Tag } from '@vitral/vue';import { ref } from 'vue'; const topics = ref(['vue', 'typescript', 'design-tokens', 'accessibility', 'layout']);</script> <template>    <Tag v-for="t in topics" :key="t" :value="t" severity="secondary" rounded removable @remove="topics = topics.filter((x) => x !== t)" />    <small v-if="!topics.length" style="color: var(--vt-text-muted-color)">All removed.</small></template>

API

Read from packages/vue/src/components/Tag/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
valuestring | number—
severitySeverityDefaults to `'primary'`.
iconIconProp—
roundedbooleanPill-shaped.
removablebooleanAdd a remove button, named "Remove <value>"; pressing it (or Delete/Backspace on it) emits `remove`.

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Emits

EventPayloadDescription
removeevent: Event—

Slots

NameSlot propsDescription
default—Replaces the value text.
icon——
removeicon——