Skip to content

API

Props

Prop NameTypeRequiredDefaultDescription
chipObject/StringYes-The chip data. Can be either a string or an object
textKeyStringNo'text'The key to use for displaying text when chip is an object
valueKeyStringNo'value'The key to use for the value when chip is an object
closableBooleanNofalseWhether to show the close button

Events

Event NameParametersDescription
onDeleteChip(value)Emitted when the close button is clicked. Returns the chip value

Slots

Slot NamePropsDescription
defaultMain content of the chip. Receives the chip prop
prependContent to be displayed before the main content. Receives the chip prop
appendContent to be displayed after the main content. Receives the chip prop
closeCustom close button content. Receives the chip prop. If not provided, uses default close icon

CSS Classes

Class NameDescription
basic-chipThe main container
chip-prependThe prepend slot container
chip-contentThe main content container
chip-appendThe append slot container
chip-closeThe close button
with-closeApplied when the chip has a close button

Component Structure

vue
<script setup>
import { computed } from 'vue'

const props = defineProps({
  chip: {
    type: [Object, String],
    required: true
  },
  textKey: {
    type: String,
    default: 'text'
  },
  valueKey: {
    type: String,
    default: 'value'
  },
  closable: {
    type: Boolean,
    default: false
  }
})

const emit = defineEmits(['onDeleteChip'])

const displayText = computed(() => {
  if (typeof props.chip === 'string') {
    return props.chip
  }
  return props.chip[props.textKey] || ''
})

const chipValue = computed(() => {
  if (typeof props.chip === 'string') {
    return props.chip
  }
  return props.chip[props.valueKey] || props.chip
})
</script>