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
3
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.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
116
Maintainers
0
Weekly downloads
 
Created
Source

@bgunnarsson/tel-input

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

Features

  • Automatic dropdown with country codes and flags.
  • Priority and exclusion of specific countries.
  • Searchable dropdown for quick country lookup.

Installation

pnpm install @bgunnarsson/tel-input

npm install @bgunnarsson/tel-input
yarn add @bgunnarsson/tel-input

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.

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