select
Select component within a Field with label and description
Select component within a Field with label and description
Загрузка превью…
src/select/c-select-8.vue
<script setup lang="ts">
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
const items = [
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
{ label: "Blueberry", value: "blueberry" },
{ label: "Grapes", value: "grapes" },
{ label: "Pineapple", value: "pineapple" },
]
</script>
<template>
<Field class="max-w-xs">
<FieldLabel for="select-fruit">Favorite Fruit</FieldLabel>
<Select>
<SelectTrigger id="select-fruit">
<SelectValue placeholder="Select a fruit" />
</SelectTrigger>
<SelectContent position="popper">
<SelectGroup>
<SelectItem v-for="item in items" :key="item.value" :value="item.value">
{{ item.label }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<FieldDescription>
Choose your favorite fruit from the list.
</FieldDescription>
</Field>
</template>