Chip
A small piece of information: a status, a tag, a filter that stays chosen. It shares its variant and tone table verbatim with VButton, and adds the two states a button does not have.
Usage
Examples
Variants and tones
variant offers three ways of painting the chip, soft, solid and outline, and tone five meanings.
Shapes
shape chooses the silhouette: chip takes the corner radius of an interactive control, pill rounds the ends completely. The chip corners read --vectis-radius-chip, which points at --vectis-radius-interactive from :root: set it to round the chips apart from the other controls. Set on a narrower selector than :root, an override of --vectis-radius-interactive does not reach the chips, so give that selector both tokens.
Sizes
size sets the height to 24 or 32 pixels, and compact takes 4px off it.
Custom colours
color replaces the tone, every shade the chip needs being derived from it. It takes any CSS colour.
With icons
iconStart and iconEnd place an icon on either side of the label, and the #start and #end slots replace them. iconFilled draws the two icons filled. A chip with no label becomes square and has to be given a name.
Clickable and links
clickable renders the chip as a button and href as a link. Given neither, it is plain text.
Selection
selectable turns the chip into a toggle bound to v-model:selected. check adds a tick before the label, in place of the start icon, and checkIcon changes its glyph.
Dismissible
dismissible adds a second button that emits dismiss, taking the chip out of the list being yours to decide. dismissIcon and dismissLabel change its glyph and its words. In a row of chips, give each cross a dismissLabel that names what it removes, or every one is announced with the same word.
States
disabled greys the chip out through the colour tokens. A disabled link has its address dropped, which leaves it neither focusable nor followable.
API
Props
| Prop | Type | Default |
|---|---|---|
variant | ChipVariant'soft' | 'solid' | 'outline' | 'soft' |
| How strongly the chip is painted: a tinted background, the full colour, or a border alone. | ||
tone | ChipTone'neutral' | 'accent' | 'danger' | 'success' | 'warning' | 'neutral' |
| What the chip means, expressed as a colour. A chip may report a state where a button may not, which is why it offers five rather than three. | ||
color | string | none |
A colour of your own, as hex, a CSS name or oklch(), which replaces the tone. Every shade it needs is derived from that one colour, so it follows both themes with nothing to rebuild. Only the contrast of the text on a fully coloured chip is yours to check. | ||
shape | ChipShape'chip' | 'pill' | 'chip' |
| The silhouette: softly rounded corners, or a full pill. | ||
size | ChipSize'xs' | 'sm' | 'xs' |
| The height of the chip. | ||
compact | boolean | false |
| Takes 4px off the height, leaving the padding, the text and the icons as they are. | ||
clickable | boolean | false |
| Makes the chip a button that reacts to clicks, without holding a state. | ||
href | string | none |
| Where the chip leads, which makes it a link. | ||
selectable | boolean | false |
Makes the chip something that stays chosen. It takes precedence over href and clickable. | ||
check | boolean | false |
| Shows a tick before the label while the chip is selected. It replaces whatever start icon was given, so the two are never shown together. | ||
checkIcon | IconSource | check |
The icon of that tick, a built-in check mark by default. iconFilled does not reach it. | ||
iconStart | IconSource | none |
An icon before the label. The #start slot replaces it. | ||
iconEnd | IconSource | none |
An icon after the label. The #end slot replaces it. | ||
iconFilled | boolean | false |
Renders iconStart and iconEnd in their filled form, the font's FILL axis. It has no effect on the slots, nor on the tick or the removal cross. | ||
dismissible | boolean | false |
| Adds a button that asks for the chip to be removed. It only emits that request: taking the chip away is your decision. | ||
dismissIcon | IconSource | close |
| The icon of that removal button. | ||
dismissLabel | string | none |
| What the removal button does, in words. It falls back to the design system dictionary. | ||
disabled | boolean | false |
| Makes the chip unusable, greyed out through the colour tokens. | ||
v-model:selected | boolean | false |
Whether the chip is selected, which is also what makes it selectable at all: binding it turns the chip into a toggle button and takes precedence over href and clickable. | ||
Events
| Event | Type |
|---|---|
dismiss | [] |
| The removal button was pressed. The chip is still on screen: removing it is yours to do. | |
Slots
| Slot | Type |
|---|---|
default | {} |
| The label. It may be left out entirely, which gives a chip made of icons alone. | |
start | {} |
Content before the label, which takes the place of iconStart. | |
end | {} |
Content after the label, which takes the place of iconEnd. | |
Types
The types the tables above name, written as the library declares them. The ones carrying export can be imported from vectis-ui to type your own code; the others are the shape of what a slot hands out.
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