Puce VChip affiche un tag, un statut ou un filtre. Il peut servir de bouton, de lien, de bascule ou d’élément supprimable.
Utilisation Design system
<script setup lang="ts">
import { VChip } from 'vectis-ui'
</script>
<template>
<VChip>Design system</VChip>
</template> Exemples Variantes et tonalités Combinez variant et tone pour définir l’apparence.
neutral soft neutral solid neutral outline
accent soft accent solid accent outline
success soft success solid success outline
warning soft warning solid warning outline
danger soft danger solid danger outline
<script setup lang="ts">
import { VChip } from 'vectis-ui'
const variants = ['soft', 'solid', 'outline'] as const
const tones = ['neutral', 'accent', 'success', 'warning', 'danger'] as const
</script>
<template>
<div v-for="tone in tones" :key="tone" class="row">
<VChip v-for="variant in variants" :key="variant" :variant="variant" :tone="tone">
{{ tone }} {{ variant }}
</VChip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style> Silhouettes shape choisit des coins arrondis ou une capsule. Personnalisez le rayon avec --vectis-radius-chip.
chip soft chip solid chip outline
pill soft pill solid pill outline
<script setup lang="ts">
import { VChip } from 'vectis-ui'
const variants = ['soft', 'solid', 'outline'] as const
const shapes = ['chip', 'pill'] as const
</script>
<template>
<div v-for="shape in shapes" :key="shape" class="row">
<VChip
v-for="variant in variants"
:key="variant"
:shape="shape"
:variant="variant"
tone="accent"
>
{{ shape }} {{ variant }}
</VChip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style> Tailles size définit la taille du chip.
<script setup lang="ts">
import { VChip } from 'vectis-ui'
</script>
<template>
<div class="row">
<VChip size="xs">Extra small</VChip>
<VChip size="sm">Small</VChip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--vectis-space-2);
}
</style> Couleurs personnalisées color remplace le ton par une couleur CSS. Vérifiez le contraste du texte sur les chips pleins.
soft solid outline selectable#0f766e mediumvioletred oklch(0.55 0.15 150)
<script setup lang="ts">
import { ref } from 'vue'
import { VChip } from 'vectis-ui'
const selected = ref(true)
</script>
<template>
<div class="row">
<VChip color="#7c3aed" variant="soft">soft</VChip>
<VChip color="#7c3aed" variant="solid">solid</VChip>
<VChip color="#7c3aed" variant="outline">outline</VChip>
<VChip v-model:selected="selected" color="#7c3aed" selectable check>selectable</VChip>
</div>
<div class="row">
<VChip color="#0f766e">#0f766e</VChip>
<VChip color="mediumvioletred">mediumvioletred</VChip>
<VChip color="oklch(0.55 0.15 150)">oklch(0.55 0.15 150)</VChip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style> Avec des icônes Utilisez les props d’icônes ou les slots start et end. Donnez un nom accessible aux chips interactifs sans texte.
Start iconEnd icon Both Operational <script setup lang="ts">
import { VChip } from 'vectis-ui'
import { arrow_right_alt as arrowRightAlt, notifications, schedule } from 'vectis-ui/icons'
</script>
<template>
<VChip :icon-start="schedule" tone="accent">Start icon</VChip>
<VChip :icon-end="arrowRightAlt" tone="accent">End icon</VChip>
<VChip :icon-start="schedule" :icon-end="arrowRightAlt" tone="accent">Both</VChip>
<VChip :icon-start="notifications" tone="danger" clickable aria-label="Notifications" />
<VChip tone="success">
<template #start><span class="dot" /></template>
Operational
</VChip>
</template>
<style scoped>
/* Use currentcolor so the custom dot follows the chip tone. */
.dot {
inline-size: 0.5rem;
aspect-ratio: 1;
border-radius: 50%;
background: currentcolor;
}
</style> Cliquable et liens clickable affiche un bouton ; href affiche un lien. Sans ces props, le chip est un contenu simple.
<script setup lang="ts">
import { ref } from 'vue'
import { VChip } from 'vectis-ui'
import { arrow_right_alt as arrowRightAlt } from 'vectis-ui/icons'
const count = ref(0)
</script>
<template>
<VChip>Static, no hover</VChip>
<VChip clickable tone="accent" @click="count += 1">Clicked {{ count }} times</VChip>
<VChip :icon-end="arrowRightAlt" href="https://vuejs.org" target="_blank" rel="noreferrer">
vuejs.org
</VChip>
</template> Sélection Activez selectable et liez v-model:selected. check affiche une coche à la place de l’icône de début lorsque le chip est sélectionné.
Vue React Svelte
Open Assigned to meArchived <script setup lang="ts">
import { ref } from 'vue'
import { VChip } from 'vectis-ui'
import { check_circle as checkCircle } from 'vectis-ui/icons'
const frameworks = ref([
{ label: 'Vue', on: true },
{ label: 'React', on: false },
{ label: 'Svelte', on: false },
])
const filters = ref([
{ label: 'Open', on: true },
{ label: 'Assigned to me', on: true },
{ label: 'Archived', on: false },
])
const labels = ref([
{ label: 'Bug', on: true },
{ label: 'Feature', on: false },
{ label: 'Docs', on: false },
])
</script>
<template>
<div class="row" role="group" aria-label="Frameworks">
<VChip
v-for="framework in frameworks"
:key="framework.label"
v-model:selected="framework.on"
selectable
tone="accent"
>
{{ framework.label }}
</VChip>
</div>
<div class="row" role="group" aria-label="Filters">
<VChip
v-for="filter in filters"
:key="filter.label"
v-model:selected="filter.on"
selectable
check
tone="accent"
>
{{ filter.label }}
</VChip>
</div>
<div class="row" role="group" aria-label="Labels">
<VChip
v-for="item in labels"
:key="item.label"
v-model:selected="item.on"
selectable
check
:check-icon="checkCircle"
tone="accent"
>
{{ item.label }}
</VChip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style> Suppression dismissible ajoute un bouton émettant dismiss. Retirez vous-même le chip. Donnez à chaque bouton un dismissLabel qui nomme l’élément retiré.
<script setup lang="ts">
import { ref } from 'vue'
import { VButton, VChip } from 'vectis-ui'
const ALL = ['Vue', 'TypeScript', 'CSS', 'Vite']
const tags = ref([...ALL])
function remove(tag: string) {
tags.value = tags.value.filter((current) => current !== tag)
}
</script>
<template>
<div class="row">
<VChip v-for="tag in tags" :key="tag" tone="accent" dismissible @dismiss="remove(tag)">
{{ tag }}
</VChip>
<VButton
v-if="tags.length < ALL.length"
variant="ghost"
tone="neutral"
size="xs"
@click="tags = [...ALL]"
>
Reset
</VButton>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--vectis-space-2);
}
</style> États disabled empêche les interactions. Les liens désactivés perdent leur destination et quittent l’ordre de tabulation.
<script setup lang="ts">
import { VChip } from 'vectis-ui'
const variants = ['soft', 'solid', 'outline'] as const
</script>
<template>
<div class="row">
<VChip v-for="variant in variants" :key="variant" :variant="variant" tone="accent" disabled>
{{ variant }}
</VChip>
</div>
<div class="row">
<VChip clickable disabled>Clickable</VChip>
<VChip href="https://vuejs.org" disabled>Inert link</VChip>
<VChip selectable check :selected="true" tone="accent" disabled>Selected</VChip>
<VChip dismissible disabled>Dismissible</VChip>
</div>
</template>
<style scoped>
.row {
display: flex;
flex-wrap: wrap;
gap: var(--vectis-space-2);
}
</style> Routeur VChip rend un vrai <a> dès que href est défini. Avec Nuxt ou Vue Router, placez-le dans le lien du routeur en mode custom et transmettez href et navigate. Un clic avec une touche de modification ouvre toujours un nouvel onglet.
<RouterLink v-slot="{ href, navigate }" to="/settings" custom>
<VChip :href="href" @click="navigate">Settings</VChip>
</RouterLink> API Props Événements Slots Types Types utilisés dans les tables d’API. Importez les types exportés depuis vectis-ui.
export interface BuiltinIcon {
name: string
paths: readonly [string] | readonly [string, string]
} export type IconRender =
| { path: string; viewBox?: string }
| { component: Component; props?: Record<string, unknown> }
| { src: string }
| { text: string; class?: string }
| { class: string } export type IconSource = string | BuiltinIcon | IconRender