Skip to main content

Type Alias: FormFieldPhoneProps<TFieldValues, TName>

FormFieldPhoneProps<TFieldValues, TName> = FormFieldProps<TFieldValues, TName> & Omit<PatternFormatProps, "name" | "format"> & object

Defined in: packages/forms/src/FormFieldPhone.tsx:92

Type Declaration​

countryCodeName?​

optional countryCodeName?: string

When provided, the selected country code is stored as a separate field in the form under this name (e.g. 'countryCode'). This allows the submitted form data to include both the full phone value and the selected calling code independently.

Example​

// Form data: { phone: '+15555555555', countryCode: '+1' }
<FormFieldPhone name="phone" label="Phone" countryCodeName="countryCode" />

countryCodeOptions?​

optional countryCodeOptions?: CountryCodeOption[]

List of country calling code options to display in the dropdown. Defaults to COMMON_PHONE_COUNTRY_CODES (15 common countries + Manual). Pass an empty array to hide the dropdown and show a plain phone input.

defaultCountryCode?​

optional defaultCountryCode?: string

The initial country calling code to display as a literal prefix in the input. For example, '+55' for Brazil or '+1' for the United States. Defaults to the first entry in countryCodeOptions when not provided. The component manages the selected code internally — no external state needed.

format?​

optional format?: string | ((value) => string)

The pattern format for the local part of the phone number. Accepts either a static string (e.g., '(##) #####-####') or a function that receives the current raw value and returns the format string, which is useful for dynamic formats (e.g., different lengths).

When the selected entry in countryCodeOptions includes its own format, that value takes precedence over this prop.

Defaults to '(###) ###-####' when neither this prop nor the selected country option supplies a format.

Ignored when countryCode is MANUAL_PHONE_COUNTRY_CODE.

onCountryCodeChange?​

optional onCountryCodeChange?: (countryCode) => void

Optional callback fired with the newly selected country code value when the user changes the country code via the dropdown. The component manages the selected code internally, so this is only needed when the caller wants to react to country-code changes.

Parameters​

ParameterType
countryCodestring

Returns​

void

Type Parameters​

Type ParameterDefault type
TFieldValues extends FieldValuesFieldValues
TName extends FieldPath<TFieldValues>FieldPath<TFieldValues>