Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bgunnarsson/tel-input

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bgunnarsson/tel-input

International Telephone Input javascript library

  • 0.0.2
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

TelInput Documentation

TelInput is a customizable telephone input field with dropdown country selection.

Features

  • Automatic dropdown with country codes and flags.
  • Default country and code configuration.
  • Priority and exclusion of specific countries.
  • Searchable dropdown for quick country lookup.
  • Pre-filled input field with country code.

Installation

  1. Include the TelInput class in your project.
  2. Ensure the loadModules function provides country and flag data.

Usage

Basic Setup

import TelInput from './path/to/tel-input.js';

const telInput = new TelInput({
  target: '.tel-input',
  wrapper: '.tel-input-wrapper',
  country: 'us', // Default country ISO code
  code: '+1', // Default country code
  exclude: ['fr', 'de'], // Countries to exclude
  priority: ['us', 'ca'], // Priority countries
  search: {
    placeholder: 'Search countries...'
  }
});

HTML Structure

<div class="tel-input">
  <div class="tel-input-wrapper">
    <input type="text" placeholder="Enter phone number">
  </div>
</div>

Config Options

OptionTypeDefaultDescription
targetstring.bg-telinputCSS selector for the target input container.
wrapperstring.bg-telinput__input-wrapCSS selector for the input wrapper.
countrystringisDefault country ISO code.
codestring+354Default country code.
excludearray[]Array of ISO codes to exclude.
priorityarray[]Array of priority ISO codes.
search.placeholderstring''Placeholder text for the search input.

Methods

Constructor

Creates a new instance of TelInput.

init()

Initializes the component, loads modules, and sets up event listeners.

Example

<div class="tel-input">
  <div class="tel-input-wrapper">
    <input type="text" placeholder="Enter phone number">
  </div>
</div>
const telInput = new TelInput({
  target: '.tel-input',
  wrapper: 'tel-input-wrapper',
  country: 'is',
  code: '+354',
  priority: ['is', 'us', 'gb'],
  exclude: ['al', 'af']
  search: {
    placeholder: 'Search countries...'
  }
});

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc