返回 slidev
SegmentControl.vue
根目录 / packages / client / internals / SegmentControl.vue
1 <script setup lang="ts">
2 import Badge from './Badge.vue'
3
4 defineProps<{
5 options: { label: string, value: any }[]
6 modelValue: any
7 }>()
8
9 defineEmits<{
10 (event: 'update:modelValue', newValue: any): void
11 }>()
12 </script>
13
14 <template>
15 <div flex="~ gap-1 items-center" rounded bg-gray:4 p1 m--1>
16 <Badge
17 v-for="option in options"
18 :key="option.value"
19 class="px-2 py-1 text-xs font-mono"
20 :class="option.value === modelValue ? '' : 'op50'"
21 :color="option.value === modelValue"
22 :aria-pressed="option.value === modelValue"
23 size="none"
24 :text="option.label"
25 as="button"
26 @click="$emit('update:modelValue', option.value)"
27 />
28 </div>
29 </template>
30
30 lines Plain Text