Components API
All form field components in react-persian-form
are built to integrate seamlessly with react-hook-form
and share a common set of props for a consistent and predictable developer experience.
Common Props
These props are available on all PersianField components.
interface PersianFormFieldProps {
/**
* The label text that appears above the form field.
*/
label: string;
/**
* The name of the field, used to register it with react-hook-form.
*/
name: string;
/**
* The control object from react-hook-form's `useForm` hook.
* This is essential for connecting the component to the form's state.
*/
control: Control<any>;
/**
* Optional helper text that appears below the field for guidance or validation messages.
*/
helperMessage?: string;
/**
* The visual style of the component. Defaults to 'primary'.
*/
variant?: "primary" | "secondary";
/**
* Any other standard HTML input attributes (e.g., placeholder, disabled, etc.).
*/
[key: string]: any;
}
Required Props:
label
: Provides a visiblelabel
for the input, crucial for accessibility and user experience.name
: A unique identifier for the form field.control
: The link between the component and thereact-hook-form
state management.