Form Select
GitHubSelect field connected to Form context with server validation errors.
Installation
bash
pnpm dlx shadcn@latest add @cs/form-selectUsage
tsx
import { FormSelect } from "@/components/cs/form-select"tsx
<FormSelect name="country" />API Reference
FormSelect
Select field connected to Form context with server validation errors.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| defaultValue | TValue | null | undefined | - | Initial selected value for uncontrolled usage. |
| label | string | undefined | - | Visible field label. |
| name * | string | - | Form field name used for submission and validation errors. |
| onValueChange | ((value: TValue | null) => void) | undefined | - | Called when the selected value changes. |
| options * | SelectOption<TValue>[] | LegacySelectOption<TValue>[] | SelectOptionsGroup<TValue>[] | - | Options rendered in the select menu. |
| orientation | "vertical" | "horizontal" | "responsive" | null | undefined | - | - |
| placeholder | string | undefined | - | Text displayed when no option is selected. |
| required | boolean | undefined | - | Requires a selected value before the form can submit. |
| selectClassName | string | undefined | - | Additional classes applied to the select trigger. |
| value | ((string | number | readonly string[]) & (TValue | null)) | undefined | - | Controlled selected value. |