Files
shadcn-ui/apps/v4/examples/base/select-with-field.tsx
2026-01-14 09:25:14 +04:00

43 lines
1.1 KiB
TypeScript

import { Field, FieldDescription, FieldLabel } from "@/examples/base/ui/field"
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/examples/base/ui/select"
export function SelectWithField() {
const items = [
{ label: "Select a fruit", value: null },
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
{ label: "Blueberry", value: "blueberry" },
{ label: "Grapes", value: "grapes" },
{ label: "Pineapple", value: "pineapple" },
]
return (
<Field>
<FieldLabel htmlFor="select-fruit">Favorite Fruit</FieldLabel>
<Select items={items}>
<SelectTrigger id="select-fruit">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{items.map((item) => (
<SelectItem key={item.value} value={item.value}>
{item.label}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
<FieldDescription>
Choose your favorite fruit from the list.
</FieldDescription>
</Field>
)
}