Keyboard shortcut: Ctrl + K
Get started

Chip

VChip displays a tag, status or filter. It can be a button, link, selectable toggle or dismissible item.

Usage

vue
Design system
<script setup lang="ts">
import { VChip } from 'vectis-ui'
</script>

<template>
  <VChip>Design system</VChip>
</template>

Examples

Variants and tones

Combine variant and tone to set the appearance.

vue
neutral softneutral solidneutral outline
accent softaccent solidaccent outline
success softsuccess solidsuccess outline
warning softwarning solidwarning outline
danger softdanger soliddanger 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>

Shapes

shape selects rounded corners or a pill. Customize the chip radius with --vectis-radius-chip.

vue
chip softchip solidchip outline
pill softpill solidpill 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>

Sizes

size sets the chip size.

vue
Extra smallSmall
<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>

Custom colours

color overrides the tone with a CSS colour. Check text contrast for solid chips.

vue
softsolidoutline
#0f766emediumvioletredoklch(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>

With icons

Use icon props or the start and end slots. Give icon-only interactive chips an accessible name.

vue
Start iconEnd iconBoth 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>

clickable renders a button; href renders a link. Without either, the chip is plain content.

vue
Static, no hover vuejs.org
<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>

Selection

Enable selectable and bind v-model:selected. check displays a tick instead of the start icon when selected.

vue
<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>

Dismissible

dismissible adds a button emitting dismiss. Remove the chip yourself. Give each button a dismissLabel naming the item it removes.

vue
VueTypeScriptCSSVite
<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>

States

disabled prevents interaction. Disabled links lose their destination and leave the tab order.

vue
softsolidoutline
Inert linkDismissible
<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>

Router

VChip renders a real <a> when href is set. With Nuxt or Vue Router, render it inside the router link in custom mode and pass on href and navigate. A click with a modifier key still opens a new tab.

vue
<RouterLink v-slot="{ href, navigate }" to="/settings" custom>
  <VChip :href="href" @click="navigate">Settings</VChip>
</RouterLink>

API

Props

PropTypeDefault
variantChipVariant'soft' | 'solid' | 'outline''soft'
Visual style.
toneChipTone'neutral' | 'accent' | 'danger' | 'success' | 'warning''neutral'
Colour tone.
colorstringnone
Custom CSS colour overriding the tone. Check text contrast for solid chips.
shapeChipShape'chip' | 'pill''chip'
Rounded corners or pill shape.
sizeChipSize'xs' | 'sm''xs'
Component size.
clickablebooleanfalse
Renders a button without selection state.
hrefstringnone
Link destination.
selectablebooleanfalse
Renders a toggle button. Takes precedence over href and clickable.
checkbooleanfalse
Shows a tick when selected, replacing start content.
checkIconIconSourcecheck
Selection tick icon. Not affected by iconFilled.
iconStartIconSourcenone
Icon before the label. Replaced by the start slot.
iconEndIconSourcenone
Icon after the label. Replaced by the end slot.
iconFilledbooleanfalse
Uses filled start and end icons when supported. Does not affect slots, tick or dismissal icon.
dismissiblebooleanfalse
Adds a dismissal button. Does not remove the chip automatically.
dismissIconIconSourceclose
Dismissal button icon.
dismissLabelstringnone
Accessible name of the dismissal button. Defaults to the library dictionary.
disabledbooleanfalse
Disables interaction.
v-model:selectedbooleanfalse
Selection state when selectable is enabled.

Events

EventType
dismiss[]
The dismissal button was activated. Remove the chip in response.

Slots

SlotType
default{}
Label content. May be omitted for an icon-only chip.
start{}
Content replacing iconStart.
end{}
Content replacing iconEnd.

Types

Types used in the API tables. Import exported types from 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