0.1.7 • Published 8 months ago
@bgunnarsson/tel-input v0.1.7
@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-inputUsage
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
| Option | Type | Default | Description |
|---|---|---|---|
target | string | .bg-telinput | CSS selector for the target input container. |
wrapper | string | .bg-telinput__input-wrap | CSS selector for the input wrapper. |
country | string | is | Default country ISO code. |
code | string | +354 | Default country code. |
exclude | array | [] | Array of ISO codes to exclude. |
priority | array | [] | Array of priority ISO codes. |
search.placeholder | string | '' | 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
8 months ago
0.1.6
8 months ago
0.1.5
10 months ago
0.1.4
10 months ago
0.1.3
11 months ago
0.1.1
11 months ago
0.1.0
11 months ago
0.0.30
1 year ago
0.0.29
1 year ago
0.0.28
1 year ago
0.0.27
1 year ago
0.0.25
1 year ago
0.0.23
1 year ago
0.0.21
1 year ago
0.0.20
1 year ago
0.0.18
1 year ago
0.0.17
1 year ago
0.0.16
1 year ago
0.0.15
1 year ago
0.0.14
1 year ago
0.0.13
1 year ago
0.0.12
1 year ago
0.0.11
1 year ago
0.0.10
1 year ago
0.0.9
1 year ago
0.0.8
1 year ago
0.0.7
1 year ago
0.0.6
1 year ago
0.0.5
1 year ago
0.0.4
1 year ago
0.0.3
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago