Skip to content

PhoneInput

function PhoneInput(__namedParameters: PhoneInputProps): Element;

Phone number input with integrated country selection, formatting and validation.

Presentational — always driven by usePhoneInput. Spread inputProps onto it and wrap it in a <FormControl> you own (spread formControlProps); the component renders its own error message into that FormControl’s context.

Parameter Type
__namedParameters PhoneInputProps

Element

const phone = usePhoneInput({ defaultCountry: "SE", isRequired: true });
<FormControl {...phone.formControlProps}>
<FormLabel>Phone number</FormLabel>
<PhoneInput {...phone.inputProps} placeholder="Enter phone number" />
</FormControl>;

Docs https://caspeco.github.io/casper-ui-library/components/phone-input