Skip to content

Props

All props are passed directly to the <TelInput> component. Props marked bindable support Svelte’s bind: syntax.

PropTypeDefaultBindableDescription
valuestring''YesE.164 formatted phone number (e.g. +36301234567). Source of truth for storage.
countryCountryCode | nullnullYesISO 3166 Alpha-2 country code (e.g. 'HU', 'US'). Auto-detected from value when not set.
validbooleantrueYesWhether the current input is a valid phone number.
validationErrorValidationErrornullYesGranular reason when valid is false. See ValidationError.
detailedValueDetailedValue | nullnullYesFull parsed result with multiple formats. See DetailedValue.
elHTMLInputElementYesReference to the underlying <input> element.
defaultCountryCountryCode | nullnullNoCountry to restore when api.reset() is called. If not set, reset clears country to null.
optionsTelInputOptions{}NoConfiguration object. See Options.

Forwarded to the underlying <input type="tel">:

PropTypeDefaultDescription
idstringAuto-generatedSets the id attribute.
namestring | nullnullSets the name attribute.
classstring''CSS class(es) applied to the input.
disabledbooleanfalseDisables the input and the parser.
readonlyboolean | nullnullMakes the input read-only.
requiredboolean | nullnullMarks the input as required. Empty input = invalid.
placeholderstring | nullnullCustom placeholder. Overrides autoPlaceholder.
sizenumber | nullnullHTML size attribute.
autocompletestring | nullnullHTML autocomplete attribute (e.g. 'tel').

Any other standard HTML input attributes are spread onto the element — including aria-* attributes.

Always stored in E.164 format — the international standard. Example: +12154567890.

<script>
let phoneNumber = $state('');
</script>
<TelInput bind:value={phoneNumber} />
<p>Stored: {phoneNumber}</p>

Accepts any ISO 3166 Alpha-2 country code. Auto-detection behavior:

  • value is +44... and country not set → auto-detects GB
  • country explicitly set → used for formatting and validation
  • User types a different dial code → country updates to match (unless lockCountry is true)

Behavior depends on validateOn and required:

Input staterequired not setrequired set
Emptytruefalse
Partial / invalidfalsefalse
Valid numbertruetrue

When valid is false, this tells you why:

ErrorMeaning
'REQUIRED'Empty input with required set
'TOO_SHORT'Not enough digits
'TOO_LONG'Too many digits
'NOT_A_NUMBER'Doesn’t look like a phone number
'INVALID_COUNTRY'Country code not recognized
'INVALID_LENGTH'Length doesn’t match any valid pattern
'COUNTRY_NOT_ALLOWED'Country not in allowedCountries
'INVALID'Fallback
nullNo error (valid)

Country to restore when api.reset() is called without { country: true }:

<TelInput defaultCountry="US" bind:country bind:value />
<!-- reset() restores country to 'US', not null -->

aria-invalid is automatically set to "true" when valid is false. You can override it explicitly if needed. All aria-* attributes pass through to the input element.