vael-ui v0.5.7

Data display

Layout

Chip

A compact token, optionally removable, for selected filters, tags or values. Use it to show choices people can take back.

Install

import { Chip } from 'vael-ui'

Playground

Chip label
Usage
<script setup lang="ts">
import { Chip } from 'vael-ui'
</script>

<template>
  <Chip label="Chip label" />
</template>

Props

NameTypeDefaultDescription
labelstringLabel text. Also names the remove button, so pass it even when using the default slot.
removablebooleanfalseShows a remove button that fires @remove.
disabledbooleanfalseDisables the remove button.
size'sm' | 'md''md'Chip size.
uiPartial<Record<'root' | 'label' | 'remove', UiPartValue>>Class and style overrides for each part.
motionChipMotionHow it moves: its appearance ({ initial: { root: { opacity: 0, scale: 0.9 } } }) and its press states ({ states: { active: { root: { scale: '0.96' } } } }). false turns its own animation off.

Events

NameTypeDescription
remove()Fires when you click the remove button, or press Delete/Backspace on a focused removable chip.

Slots

NameTypeDescription
defaultanyLabel content; replaces the label text. The remove button keeps its name from label.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Chip: its appearance and press states.

<Chip
  :motion="{ states: { disabled: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitrootremoveSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statesdisabledfocusactivehoverSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

KeyAction
DeleteBackspaceFires remove when the chip is removable and focus is on the chip or its remove button.
EnterSpaceFires remove from the focused remove button.
  • The remove button is a <button> named “Remove” plus the label. Pass label even when you use the default slot, or the button is named only “Remove”.
  • When a chip that holds focus is removed, focus moves to the next chip, the previous one, or the field of the Select, CascadeSelect or Combobox it belongs to.
  • The chip root is not focusable on its own. Add tabindex="0" for Delete and Backspace to work on the chip itself.
  • Inside an element with role="combobox" or role="button", such as a Select trigger, the remove button is pointer only (tabindex="-1", aria-hidden). With disabled, it is disabled and the keys do nothing.