Select
Displays a list of options for the user to pick from, triggered by a button.
Installation
npx shadcn-vue@latest add https://vuedocs.canceydejean.dev/r/select.jsonUsage
Use select for a single choice from a list of options when a native <select> would be too
limited to style, or when you need grouped options, labels, and separators.
<script setup lang="ts">
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
</script>
<template>
<Select>
<SelectTrigger class="w-[180px]">
<SelectValue placeholder="Select a fruit" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
<SelectItem value="blueberry">Blueberry</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</template>
Built on reka-ui's Select primitive; SelectTrigger
accepts size="sm" for a denser control.