react-hook-form-bound text field. Wraps the @uxf/ui/text-input primitive and manages its value, isInvalid, and helperText from form state.
Use @uxf/form/text-input for a text field 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 text input (outside a form), use the @uxf/ui/text-input twin directly.
import { Form } from "@uxf/form/form";
import { TextInput } from "@uxf/form/text-input";
import { useForm } from "react-hook-form";
interface FormData {
email: string;
}
function Example() {
const formApi = useForm<FormData>({ defaultValues: { email: "" } });
return (
<Form formApi={formApi} id="example" onSubmit={(values) => console.log(values)}>
<TextInput control={formApi.control} isRequired label="E-mail" name="email" type="email" />
</Form>
);
}
Value is string | null (rendered as an empty string when null).
TextInputProps<FormData> = ControlProps<FormData> + the visual props of the @uxf/ui/text-input twin (minus the ones this field manages: isInvalid, name, onChange, value, …) + the validation 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 validation below. |
shouldUnregister | boolean | — | Unregister the field (drop its value) on unmount. |
type | "text" | "password" | "search" | "url" | "email" | "tel" | "text" | Input type; email/tel/url add built-in format validation. |
isRequired | boolean | false | Adds a required rule and the required indicator. |
requiredMessage | string | localized | Message for the required rule. |
invalidEmailMessage / invalidPhoneMessage / invalidUrlMessage | string | localized | Message for the matching format check (only valid for the corresponding type). |
onChange | (value: string | null, event) => void | — | Called after the field value updates. |
All other props (label, placeholder, size, variant, helperText, leftAddon/rightAddon/leftElement/rightElement, maxLength, autoComplete, …) are forwarded to the twin — see @uxf/ui/text-input.
isRequired adds a required rule (requiredMessage to override the message).type="email" | "tel" | "url" adds a format check; override its message with invalidEmailMessage / invalidPhoneMessage / invalidUrlMessage.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/text-input, so include that component's stylesheet(s) and the @uxf/ui token layer — see @uxf/ui/text-input.@uxf/ui/text-input