mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
49 lines
945 B
Vue
49 lines
945 B
Vue
<script setup lang="ts">
|
|
import type { SelectItem, ChipProps } from '@nuxt/ui'
|
|
|
|
const items = ref([
|
|
{
|
|
label: 'bug',
|
|
value: 'bug',
|
|
chip: {
|
|
color: 'error'
|
|
}
|
|
},
|
|
{
|
|
label: 'feature',
|
|
value: 'feature',
|
|
chip: {
|
|
color: 'success'
|
|
}
|
|
},
|
|
{
|
|
label: 'enhancement',
|
|
value: 'enhancement',
|
|
chip: {
|
|
color: 'info'
|
|
}
|
|
}
|
|
] satisfies SelectItem[])
|
|
|
|
const value = ref(items.value[0]?.value)
|
|
|
|
function getChip(value: string) {
|
|
return items.value.find(item => item.value === value)?.chip
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<USelect v-model="value" :items="items" value-key="value" class="w-48">
|
|
<template #leading="{ modelValue, ui }">
|
|
<UChip
|
|
v-if="modelValue"
|
|
v-bind="getChip(modelValue)"
|
|
inset
|
|
standalone
|
|
:size="(ui.itemLeadingChipSize() as ChipProps['size'])"
|
|
:class="ui.itemLeadingChip()"
|
|
/>
|
|
</template>
|
|
</USelect>
|
|
</template>
|