Skip to content
v2.5.0
English
Русский
Documentation

PhoneField

PhoneField is a compound component that combines a masked phone input with a nested country-code Select.

Root API

PhoneField owns the phone input and country formatting model.

PropTypeDefault
valuestring—
Controlled phone number, as the text of the input.
defaultValuestring''
Initial phone number for uncontrolled usage. Defaults to ''. Its country is selected unless code is set.
onChangeValue(value: string) => void—
Called with the phone number when it changes.
codeCountryCode—
ISO 3166-1 alpha-2 country code used to determine the phone mask format. Example: 'US', 'RU', 'FR'.
defaultCodeCountryCode''
ISO 3166-1 alpha-2 country code used to determine the phone mask format. Example: 'US', 'RU', 'FR'.
onChangeCode(code: CountryCode) => void—
ISO 3166-1 alpha-2 country code used to determine the phone mask format. Example: 'US', 'RU', 'FR'.
strictMaskbooleantrue
If true, enforces the phone number mask strictly — only valid characters in the correct positions are allowed.
sizeTextFieldSize—
Visual size of the text field. Affects padding, font size, and overall height. 'sm': Compact input; 'md': Default; 'lg': Spacious layout
refRef<HTMLDivElement>—
Ref forwarded to wrapper element Useful for programmatic control, focus, or integration.
errorboolean—
Shows the input in an error state.

Also accepts all <div> attributes.

Child Parts API

PhoneFieldInput

Visible text input for the phone number.

PropTypeDefault
refRef<HTMLInputElement>—
Ref forwarded to the underlying native <input> element.

Also accepts all <input> attributes.

PhoneFieldSelect*

Nested country-select family built around the same field state.

  • PhoneFieldSelect
  • PhoneFieldSelectHiddenSelect
  • PhoneFieldSelectCombobox
  • PhoneFieldSelectValue
  • PhoneFieldSelectIcon
  • PhoneFieldSelectListbox
  • PhoneFieldSelectOption

PhoneFieldSelect

PropTypeDefault
sizeSelectSize—
Visual size of the select control.
variantSelectVariant—
Visual style variant for the select control.
disabledboolean—
Whether the select is disabled. Prevents interaction and applies a disabled style.
onChangeValue(value: V | undefined) => void—
Callback fired when an option is selected.
refRef<HTMLDivElement>—
Ref to the root element.
readOnlyboolean—
If true, the select cannot be changed but remains focusable.
typeaheadbooleantrue
Enables moving to an option by typing the start of its label.
openboolean—
Controls the open state of the Select dropdown. When provided, the Select becomes a controlled component and relies on this value to determine whether the listbox is open or closed.
onChangeOpen(open: boolean) => void—
Callback fired when the open state changes. Called with the next open state (true or false) whenever the Select is opened or closed by user interaction. Useful for synchronizing the Select state with external logic.
defaultOpenboolean—
Sets the initial open state of the Select when used in uncontrolled mode. Applied only on the first render and ignored afterward.

Also accepts all <div> attributes.

PhoneFieldSelectHiddenSelect

Also accepts all <select> attributes.

PhoneFieldSelectCombobox

PropTypeDefault
refRef<HTMLButtonElement>—
Ref to the underlying <button> element. Useful for focus management, positioning, and imperative access.

Also accepts all <button> attributes.

PhoneFieldSelectValue

PropTypeDefault
placeholderstring—
Placeholder text shown when no option is selected. Displayed when the select value is empty or undefined. Once a value is selected, the placeholder is replaced by the selected option’s content.
refRef<HTMLSpanElement>—
Ref forwarded to the root span element.

Also accepts all <span> attributes.

PhoneFieldSelectIcon

PropTypeDefault
sizeIconSize—
Predefined size token for the icon. Can be overridden by explicit width and height.
refRef<SVGSVGElement>—
Ref to the SVG element
strokeWidthnumber—
Stroke thickness for SVG lines and shapes (in px or pt).
childrenReactNode—
Icon content (required). Accepts: icons from ~/icons; custom inline SVG; third-party icon components (e.g. Lucide, Tabler)

Also accepts all HTML attributes.

PhoneFieldSelectOption

PropTypeDefault
valuerequiredCountryCode—
The value of this option, passed to the change callback when it is selected.
labelstring—
Plain text of this option for typeahead, used instead of the text of its content.
childrenReactNode—
The content displayed for this option. Can include text, icons, or complex markup.
sizeOptionSize—
Size of the option for visual styling.
disabledboolean—
Disables the entire Option.
refRef<HTMLDivElement>—
Ref forwarded to the root div of the option.

Also accepts all <div> attributes.

PhoneFieldSelectListbox

PropTypeDefault
refRef<HTMLDivElement>—
Ref to the listbox container element. Can be used for imperative access, for example measurements.

Also accepts all <div> attributes.

Hooks

usePhoneFieldContext

Advanced hook for custom wrappers and integrations.

Types

TypeDefinitionNotes
PhoneFieldPropsRoot prop typeMain field integration surface.
PhoneFieldInputPropsInput part prop typeNumber input behavior.
PhoneFieldSelectPropsSelect root prop typeNested country picker surface.

State Model

  • Root state coordinates country and input formatting.
  • Strict and non-strict masking affect input tolerance.
  • Nested select composition should still be treated as one field family.

Integration Notes

  • Validate and normalize canonical values outside the presentation layer.
  • Retest paste and autofill behavior, not only key-by-key typing.
  • Keep country changes and validation logic synchronized.