react-hook-form-bound checkbox field. Wraps the @uxf/ui/checkbox-input primitive and manages its value, isInvalid, and helperText from form state.
Use @uxf/form/checkbox-input for a labeled checkbox 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 checkbox (outside a form), use the @uxf/ui/checkbox-input twin directly.
import { CheckboxInput } from "@uxf/form/checkbox-input";
import { Form } from "@uxf/form/form";
import { useForm } from "react-hook-form";
interface FormData {
agree: boolean;
}
function Example() {
const formApi = useForm<FormData>({ defaultValues: { agree: false } });
return (
<Form formApi={formApi} id="example" onSubmit={(values) => console.log(values)}>
<CheckboxInput control={formApi.control} isRequired label="I agree" name="agree" />
</Form>
);
}
Value is boolean | undefined.
CheckboxInputProps<FormData> = ControlProps<FormData> + the visual props of the @uxf/ui/checkbox-input 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. |
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: boolean | undefined, event?) => void | — | Called after the field value updates. |
onChangeConfirm | (value: boolean | undefined) => Promise<boolean> | — | Async guard run before committing a change; the value is written only if it resolves true. |
All other props (label, hiddenLabel, size, helperText, …) are forwarded to the twin — see @uxf/ui/checkbox-input.
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.Form — it reads the form context (formId, and inherits isDisabled / isReadOnly) and needs a react-hook-form control.@uxf/ui/checkbox-input, so include that component's stylesheet(s) and the @uxf/ui token layer — see @uxf/ui/checkbox-input.@uxf/ui/checkbox-input