phone-mask Svelte Themes

Phone Mask

โšก Ultra-lightweight international phone number formatter & validator with auto-sync to Google libphonenumber

๐Ÿ“ฑ Phone Mask

Always-fresh, extreme small & easy-to-use international phone masking with Google's libphonenumber data

npm version npm downloads bundle size code coverage license

Quick Start โ€ข Packages โ€ข Features โ€ข Demo โ€ข Contributing


๐ŸŽฏ Why Phone Mask?

๐Ÿ”„ Always Up-to-Date

Phone formats sync automatically from Google's libphonenumber โ€” no stale data, no manual updates. Just upgrade and you're current with global dialing rules.

๐Ÿชถ Lightest in Class

Real market comparison, segmented by ecosystem and measured for what developers actually ship. Snapshot: 2026-03-27 (Bundlephobia API, Bundlephobia Exports API, npm Registry API).

Use Total gzip as the primary comparison column. Gzip is Bundlephobia raw package gzip. Data overhead is additional phone-data gzip excluded from raw package gzip (e.g. required peer engines). When available, export-level Bundlephobia sizes are used for better precision. Total gzip = Gzip + Data overhead.

Core (TypeScript/JavaScript)

Package Last published Phone data source Data overhead Gzip Total gzip
@desource/phone-mask ยท Repo 2026-03-25 Included in package 0.0 KB 5.1 KB 5.1 KB
libphonenumber-js ยท Repo 2026-03-13 Included in package 0.0 KB 43.7 KB 43.7 KB
awesome-phonenumber ยท Repo 2026-02-18 Included in package 0.0 KB 75.4 KB 75.4 KB
google-libphonenumber ยท Repo 2026-01-19 Included in package 0.0 KB 115.2 KB 115.2 KB

Best choice in Core (TypeScript/JavaScript): @desource/phone-mask (5.1 KB).

React

Package Last published Phone data source Data overhead Gzip Total gzip
@desource/phone-mask-react ยท Repo 2026-03-25 @desource/phone-mask (dep) 0.0 KB 9.2 KB 9.2 KB
react-international-phone ยท Repo 2026-02-21 None 0.0 KB 9.4 KB 9.4 KB
react-phone-input-2 ยท Repo 2022-07-01 Included in package 0.0 KB 17.1 KB 17.1 KB
mui-tel-input ยท Repo 2025-05-18 libphonenumber-js (dep) 0.0 KB 45.8 KB 45.8 KB
react-phone-number-input ยท Repo 2026-02-23 libphonenumber-js (dep) 0.0 KB 46.7 KB 46.7 KB

Best choice in React: @desource/phone-mask-react (9.2 KB).

React ecosystem note: react-international-phone removed built-in validation in v3 and recommends adding google-libphonenumber separately (migration doc). Raw package gzip above does not include that optional validator overhead.

Vue

Package Last published Phone data source Data overhead Gzip Total gzip
@desource/phone-mask-vue ยท Repo 2026-03-25 @desource/phone-mask (dep) 0.0 KB 10.5 KB 10.5 KB
v-phone-input ยท Repo 2026-03-11 awesome-phonenumber (dep) 0.0 KB 15.0 KB 15.0 KB
vue-tel-input ยท Repo 2026-03-19 libphonenumber-js (peer: parsePhoneNumberFromString) 28.5 KB 10.3 KB 38.8 KB
vue-phone-number-input ยท Repo 2022-09-20 libphonenumber-js (dep) 0.0 KB 95.7 KB 95.7 KB

Best choice in Vue: @desource/phone-mask-vue (10.5 KB).

Svelte

Package Last published Phone data source Data overhead Gzip Total gzip
@desource/phone-mask-svelte ยท Repo 2026-03-25 @desource/phone-mask (dep) 0.0 KB 11.1 KB 11.1 KB
svelte-tel-input ยท Repo 2026-03-26 libphonenumber-js (dep) N/A N/A N/A

Best choice in Svelte: @desource/phone-mask-svelte (11.1 KB).

Nuxt

Package Last published Phone data source Data overhead Gzip Total gzip
@desource/phone-mask-nuxt ยท Repo 2026-03-25 @desource/phone-mask-vue (runtime: install) 10.1 KB 0.7 KB 10.9 KB

Best choice in Nuxt: @desource/phone-mask-nuxt (10.9 KB).

Nuxt ecosystem note: there are currently no widely adopted Nuxt-only phone input modules with stable npm + Bundlephobia signals comparable to React/Vue/Svelte peers; most Nuxt apps use Vue phone input packages directly.

๐ŸŽจ Framework-Ready

Ready-made plugins for your stack:

  • โœ… Vue 3 โ€” Component, composable, and directive
  • โœ… Nuxt โ€” Auto-imported, SSR-compatible
  • โœ… React โ€” Component & hook with modern React patterns
  • โœ… Svelte โ€” Component, composable, action, and attachment for Svelte 5
  • โœ… TypeScript/Vanilla JS โ€” Framework-agnostic core

๐Ÿ“ฆ Packages

Package Version Description
@desource/phone-mask Core library โ€” TypeScript/JS
@desource/phone-mask-react React component + hook
@desource/phone-mask-vue Vue 3 component + composable + directive
@desource/phone-mask-svelte Svelte 5 component + composable + action + attachment
@desource/phone-mask-nuxt Nuxt module

โšก Quick Start

React

npm install @desource/phone-mask-react
import { useState } from 'react';
import { PhoneInput } from '@desource/phone-mask-react';
import '@desource/phone-mask-react/assets/lib.css';

function App() {
  const [phone, setPhone] = useState('');

  return <PhoneInput value={phone} onChange={setPhone} country="US" />;
}

Vue 3

npm install @desource/phone-mask-vue
<script setup>
import { ref } from 'vue';
import { PhoneInput } from '@desource/phone-mask-vue';
import '@desource/phone-mask-vue/assets/lib.css';

const phone = ref('');
</script>

<template>
  <PhoneInput v-model="phone" country="US" />
</template>

Svelte 5

npm install @desource/phone-mask-svelte
<script lang="ts">
import { PhoneInput } from '@desource/phone-mask-svelte';
import '@desource/phone-mask-svelte/assets/lib.css';

let phone = $state('');
</script>

<PhoneInput bind:value={phone} country="US" />

Nuxt

npm install @desource/phone-mask-nuxt
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@desource/phone-mask-nuxt']
});
<script setup>
import { ref } from 'vue';

const phone = ref('');
</script>

<template>
  <PhoneInput v-model="phone" country="US" />
</template>

TypeScript/Vanilla JS

npm install @desource/phone-mask
import { MasksFullMapEn, formatDigitsWithMap } from '@desource/phone-mask';

const mask = MasksFullMapEn.US.mask[0]; // "###-###-####"
const formatted = formatDigitsWithMap(mask, '2025551234').display;
// Result: "202-555-1234"

โœจ Features

  • ๐ŸŒ 240+ countries with accurate dialing codes and formats
  • ๐ŸŽญ Auto-formatting as you type with smart cursor positioning
  • ๐Ÿ” Country search with fuzzy matching and keyboard navigation
  • ๐ŸŒ Auto-detection via GeoIP and browser locale
  • ๐Ÿ“‹ Copy to clipboard with one click
  • โœจ Validation with visual feedback
  • ๐ŸŽจ Themeable (light/dark) with custom styling
  • โ™ฟ Accessible with ARIA labels and keyboard support
  • ๐Ÿ“ฑ Mobile-optimized with proper input modes
  • ๐ŸŒณ Tree-shakeable โ€” only import what you use
  • ๐Ÿ”ง TypeScript โ€” full type safety
  • ๐Ÿงฉ Directive mode for custom input styling

๐ŸŽฎ Demo

Live Demo โ†’

Try the interactive playground with:

  • Real-time formatting preview
  • Country switching
  • Theme toggle
  • Code examples

๐Ÿ“š Documentation


๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Flow

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/YOUR_USERNAME/phone-mask.git
  3. Install dependencies: pnpm install
  4. Create a branch: git checkout -b feature/my-feature
  5. Make your changes
  6. Commit: git commit -m "feat: add awesome feature"
  7. Push: git push origin feature/my-feature
  8. Open a Pull Request

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run unit tests with coverage report
pnpm test:unit:coverage

# Start demo dev server
pnpm dev:prepare
pnpm dev:demo

# Generate fresh data from Google's library
pnpm gen

๐ŸŒŸ Sponsors

Developed and maintained by DeSource Labs.

DeSource Labs

Created by Stefan Popov


๐Ÿ“„ License

MIT ยฉ 2026 DeSource Labs



Built with โค๏ธ by the DeSource Labs team

Top categories

Loading Svelte Themes