0.1.7 • Published 5 months ago

@bgunnarsson/tel-input v0.1.7

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

@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.

0.1.7

5 months ago

0.1.6

6 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago

0.0.30

11 months ago

0.0.29

11 months ago

0.0.28

11 months ago

0.0.27

11 months ago

0.0.25

11 months ago

0.0.23

11 months ago

0.0.21

11 months ago

0.0.20

11 months ago

0.0.18

11 months ago

0.0.17

11 months ago

0.0.16

11 months ago

0.0.15

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago