Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz. Click a select, or Tab to it and press Space.
Choose one option
A label above the field, linked with for and id, and a placeholder that says what to do.
SelectBasic.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
const status = ref<string>()
const statuses = [
{ value: 'pending', label: 'Pending' },
{ value: 'processing', label: 'Processing' },
{ value: 'shipped', label: 'Shipped' },
{ value: 'cancelled', label: 'Cancelled' },
]
</script>
<template>
<div class="grid w-full max-w-64 gap-(--bh-space-100)">
<label for="order-status" class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">Order status</label>
<Select v-model="status">
<SelectTrigger id="order-status" class="w-full">
<SelectValue placeholder="Choose a status" />
</SelectTrigger>
<SelectContent>
<SelectItem v-for="item in statuses" :key="item.value" :value="item.value">
{{ item.label }}
</SelectItem>
</SelectContent>
</Select>
</div>
</template>Groups
Group headings and separators split a long list. The last option, “Don’t send”, has the value none: a select value can’t be the empty string. A disabled option says why in its text.
SelectGroups.vue
<script setup lang="ts">
import { ref } from 'vue'
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectSeparator,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
// 'none' stands for "no destination": a select value can't be the empty string.
const destination = ref('erp-main')
</script>
<template>
<div class="grid w-full max-w-64 gap-(--bh-space-100)">
<label for="order-destination" class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">Send new orders to</label>
<Select v-model="destination">
<SelectTrigger id="order-destination" class="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>ERP</SelectLabel>
<SelectItem value="erp-main">Main ERP</SelectItem>
<SelectItem value="erp-warehouse">Warehouse ERP</SelectItem>
</SelectGroup>
<SelectSeparator />
<SelectGroup>
<SelectLabel>CRM</SelectLabel>
<SelectItem value="crm-sales">Sales CRM</SelectItem>
<SelectItem value="crm-support" disabled>Support CRM (not connected)</SelectItem>
</SelectGroup>
<SelectSeparator />
<SelectItem value="none">Don't send</SelectItem>
</SelectContent>
</Select>
</div>
</template>Small, disabled and invalid
A small select in a table footer, a disabled one with the reason under it, and one with an error that says how to fix it.
The connected ERP sets tax for this store.
Choose a currency to publish prices.
SelectStates.vue
<script setup lang="ts">
import { ref } from 'vue'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
const pageSize = ref('25')
const currency = ref<string>()
</script>
<template>
<div class="grid w-full max-w-64 gap-(--bh-space-300)">
<div class="flex items-center gap-(--bh-space-100)">
<label for="rows-per-page" class="text-(--bh-color-text-subtle) [font:var(--bh-font-body-small)]">Rows per page</label>
<Select v-model="pageSize">
<SelectTrigger id="rows-per-page" size="sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="25">25</SelectItem>
<SelectItem value="50">50</SelectItem>
<SelectItem value="100">100</SelectItem>
</SelectContent>
</Select>
</div>
<div class="grid gap-(--bh-space-100)">
<label for="tax-rule" class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">Tax rule</label>
<Select disabled>
<SelectTrigger id="tax-rule" class="w-full" aria-describedby="tax-rule-hint">
<SelectValue placeholder="Set by the ERP" />
</SelectTrigger>
<SelectContent>
<SelectItem value="erp">Set by the ERP</SelectItem>
</SelectContent>
</Select>
<p id="tax-rule-hint" class="m-0 text-(--bh-color-text-subtle) [font:var(--bh-font-body-small)]">The connected ERP sets tax for this store.</p>
</div>
<div class="grid gap-(--bh-space-100)">
<label for="store-currency" class="text-(--bh-color-text) [font:var(--bh-font-label-default)]">Store currency</label>
<Select v-model="currency">
<SelectTrigger id="store-currency" class="w-full" :aria-invalid="!currency" aria-describedby="store-currency-error">
<SelectValue placeholder="Choose a currency" />
</SelectTrigger>
<SelectContent>
<SelectItem value="usd">US dollar (USD)</SelectItem>
<SelectItem value="vnd">Vietnamese dong (VND)</SelectItem>
<SelectItem value="eur">Euro (EUR)</SelectItem>
</SelectContent>
</Select>
<p v-if="!currency" id="store-currency-error" class="m-0 text-(--bh-color-text-danger) [font:var(--bh-font-body-small)]">Choose a currency to publish prices.</p>
</div>
</div>
</template>