Skip to main content

Phone Input

A phone inputs with country code and national number.

Examples

Basic Example

The following example demonstrate some of the available functionality for read_phone

from abstra.forms import read_phone

phone = read_phone("What is your phone number?")
number = phone.raw # eg: 5521999999999
masked = phone.masked # eg: +55 (21) 99999-9999

Parameters

NameDescriptionType
labelThe label to display to the userstr
initial_valueThe initial value to display to the user. It contains two keys: 'country_code' (string with optional + sign or number) and 'national_number' (str). Ex: {'country_code': '55', 'national_number': '21999990000'}.dict
placeholderThe placeholder text to display in the national number input. Defaults to "".str
invalid_messageThe message to display when the input is invalidstr
disabledwhether the input is disabled. Defaults to False.bool
requiredWhether the input is required or not eg. "this field is required". Defaults to True.Union[bool, str]
hintA tooltip displayed to the user. Defaults to None.str
full_widthWhether the input should use full screen width. Defaults to False.bool
button_textWhat text to display on the button when the widget is not part of a Page. Defaults to 'Next'.str

Return Values

TypeDescription
PhoneResponseA dict containing the value entered by the user ({"country_code": str, "national_number": str})