react-hook-form-bound field: a labeled group of mutually exclusive radio options bound to a single value. Wraps the @uxf/ui/radio-group primitive and manages its value, isInvalid, and helperText from form state.
Use @uxf/form/radio-group for a single choice from a fixed set of options inside a @uxf/form form — it registers the field with react-hook-form via control/name. For a standalone, manually-controlled radio group (outside a form), use the @uxf/ui/radio-group twin directly.
import { RadioGroup } from "@uxf/form/radio-group";
import { Form } from "@uxf/form/form";
import { useForm } from "react-hook-form";
interface FormData {
choice: string | null;
}
const OPTIONS = [
{ id: "1", label: "Radio one" },
{ id: "2", label: "Radio two" },
{ id: "3", label: "Radio three" },
];
function Example() {
const formApi = useForm<FormData>({ defaultValues: { choice: null } });
return (
<Form formApi={formApi} id="example" onSubmit={(values) => console.log(values)}>
<RadioGroup control={formApi.control} isRequired label="Choose one" name="choice" options={OPTIONS} />
</Form>
);
}
Value is the selected option id (ValueId | null, where ValueId is string | number).
RadioGroupProps<FormData> = ControlProps<FormData> + the visual props of the @uxf/ui/radio-group twin (minus the ones this field manages: isFocused, isInvalid, name, onChange, value) + the field props below.
| Prop | Type | Default | Description |
|---|---|---|---|
control |
Control<FormData> |
— | Required. The control from useForm. |
name |
FieldPath<FormData> |
— | Required. Field path in the form values. |
options |
RadioGroupOption[] |
— | Required. Options to render ({ id, label, disabled? }); see the twin. |
rules |
RegisterOptions |
— | Extra react-hook-form rules; merged with the built-in required rule. |
shouldUnregister |
boolean |
— | Unregister the field (drop its value) on unmount. |
isRequired |
boolean |
false |
Adds a required rule and the required indicator. |
requiredMessage |
string |
localized | Message for the required rule. |
onChange |
(value: ValueId | null, event?) => void |
— | Called after the field value updates. |
onChangeConfirm |
(value: ValueId | null) => Promise<boolean> |
— | Async guard run before committing a change; the value is written only if it resolves true. |
All other props (label, variant, radioSize, hiddenLabel, helperText, …) are forwarded to the twin — see @uxf/ui/radio-group.
isRequired adds a required rule; its message defaults to a localized string (EN: "This field is required") and can be overridden with requiredMessage.rules; the field-level error is shown as the twin's helperText and sets isInvalid.options is empty.Form — it reads the form context (formId, and inherits isDisabled / isReadOnly) and needs a react-hook-form control.@uxf/ui/radio-group, so include that component's stylesheet(s) and the @uxf/ui token layer — see @uxf/ui/radio-group.@uxf/ui/radio-group