react-hook-form-bound single-value dropdown. Wraps the @uxf/ui/select primitive and manages its value, isInvalid, and helperText from form state.
Use @uxf/form/select for a single-choice picker inside a @uxf/form form — it registers the field with react-hook-form via control/name and renders validation errors automatically. For a standalone, manually-controlled select (outside a form), use the @uxf/ui/select twin directly.
@uxf/form/combobox.@uxf/form/multi-select.import { Form } from "@uxf/form/form";
import { Select, SelectValue } from "@uxf/form/select";
import { useForm } from "react-hook-form";
interface FormData {
country: SelectValue<string>;
}
const options = [
{ id: "cz", label: "Czechia" },
{ id: "sk", label: "Slovakia" },
];
function Example() {
const formApi = useForm<FormData>({ defaultValues: { country: null } });
return (
<Form formApi={formApi} id="example" onSubmit={(values) => console.log(values)}>
<Select
control={formApi.control}
isRequired
label="Country"
name="country"
options={options}
placeholder="Select..."
/>
</Form>
);
}
The react-hook-form value is the selected option's id (string | number) or null — the same shape as the @uxf/ui/select twin (SelectValue<T> = T | null). It is read from and written to the twin unchanged (no normalisation).
SelectProps<FormData> = ControlProps<FormData> + the visual props of the @uxf/ui/select twin (minus the ones this field manages: inputGroupRef, inputRef, inputWrapperRef, isFocused, isInvalid, name, onChange, value) + the field-specific props below.
| Prop | Type | Default | Description |
|---|---|---|---|
control |
Control<FormData> |
— | Required. The control from useForm. |
name |
FieldPath<FormData> |
— | Required. Field path in the form values. |
rules |
RegisterOptions |
— | Extra react-hook-form rules; merged with the built-in required rule below. |
shouldUnregister |
boolean |
— | Unregister the field (drop its value) on unmount. |
isRequired |
boolean |
false |
Adds a required rule and the required indicator on the label. |
requiredMessage |
string |
localized | Overrides the required rule message. |
onChange |
(value: SelectValue<T>, event) => void |
— | Called after the field value updates. |
onChangeConfirm |
(value) => Promise<boolean> |
— | Async gate: the change is committed only if the returned promise resolves true. |
All visual props (label, options, placeholder, isClearable, size, variant, helperText, renderOption, renderSelectedOption, keyExtractor, iconName, leftAddon/rightAddon/leftElement/rightElement, the dropdown* props, …) are forwarded to the twin — see @uxf/ui/select.
isRequired adds a required rule; override its message with requiredMessage (default localized "This field is required", key uxf-form-select:validation.required).rules; they are merged with the built-in rule.helperText and sets isInvalid.Form — it reads the form context (formId for the default id = ${formId}__${name}, and inherits isDisabled / isReadOnly) and needs a react-hook-form control.options is empty (in addition to the form's isDisabled and the field's own isDisabled).@uxf/ui/select, so include that component's stylesheet(s) and the @uxf/ui token layer — see @uxf/ui/select.@uxf/ui/select