Form Select

GitHub

Select field connected to Form context with server validation errors.

Installation

bash
pnpm dlx shadcn@latest add @cs/form-select

Usage

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

NameTypeDefaultDescription
defaultValueTValue | null | undefined-Initial selected value for uncontrolled usage.
labelstring | 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--
placeholderstring | undefined-Text displayed when no option is selected.
requiredboolean | undefined-Requires a selected value before the form can submit.
selectClassNamestring | undefined-Additional classes applied to the select trigger.
value((string | number | readonly string[]) & (TValue | null)) | undefined-Controlled selected value.