Documentation
Form Components
Phone Input

Phone Input

The PhoneInput component is designed for accurate and user-friendly phone number entry. It features an intuitive interface that allows users to input their phone numbers with automatic formatting and validation based on international standards.

Installation

Install the package

npm i @start-base/react-form-elements

Add the styles

To use the React form elements styles in a Next.js project, import the styles in your layout.tsx file.

app/layout.tsx
import "@start-base/react-form-elements/styles.css";

Import the component

import PhoneInput from '@start-base/react-form-elements/PhoneInput';

Usages

Phone Input With Label

Phone Input With Placeholder

Phone Input With Placeholder And Label

Phone Input With Placeholder And Label And Disable Shrink

Phone Input Disabled

Phone Input Prepend

Phone Input Error

Error Message

API

This component is a wrapper around react-international-phone (opens in a new tab) component.

NameTypeDefaultDescription
namestringName of the input
labelstringnullLabel of the input
placeholderstringnullPlaceholder of the input
disableShrinkbooleanfalsePosition the label outside of the input
valuestring or numberValue of the input
onChangefunctionCallback function that is fired when the value changes.
inputClassNamestringnullClassname for input element
labelClassNamestringnullClassname for label element
errorClassNamestringnullClassname for error element
disabledbooleanfalseDisable the input
errorstring or boolean or objectnullError message to display below the input. if value is a boolean input border will be change. Also you can pass schema validator error objects.
defaultCountrystringusDefault country code for phone starting code and flag
prependstring or elementnullPrepend text to the input
appendstring or elementnullAppend text to the input
appendClassNamestringnullClassname for append element
prependClassNamestringnullClassname for prepend element

Styling