npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svelte-tel

v0.0.5

Published

Simple headless phone number input handling for Svelte.

Readme

svelte-tel

Simple headless phone number input handling for Svelte.

View Demo npm GitHub Workflow Status

[!WARNING] This library is in alpha stages and may have breaking changes in the future.

(it definitely will)

Motivation and Goals

The library is fully headless, so you can use it however you want. All logic should be handled by the library, and the UI to be handled by you. This way, you can have full control over the look and feel of your phone input. I also want to make it entirely based on Runes so you get the full power of Svelte.

Future things I'm considering:

  • More options for the class.
  • Pre-built components.

If you have any suggestions, feel free to open an issue and we can discuss it.

Installation

npm install svelte-tel

Usage

<script>
  import { Tel } from "svelte-tel";

  // Initialize the class
  const tel = new Tel();
</script>

<!-- Bind the value to the input -->
<input type="tel" bind:value={tel.value} />

<!-- Now you can access the country data and the raw phone number -->

<p>Country Code: {tel.country}</p>
<p>Internationally formatted: {tel.value}</p>
<p>Nationally formatted: {tel.national}</p>
<p>Raw Phone Number: {tel.number}</p>
<p>Is Valid: {tel.valid}</p>
<p>Is Possible: {tel.possible}</p>

🎉 That's literally it 🎉

More complex example

Now you can use tel to do whatever you want. Here's an example of how you might create a phone input with a country selector.

<script lang="ts">
  import { Tel } from "svelte-tel";
  import { getFlagEmoji } from "path-to-your-flag-emoji-function";

  let input: HTMLInputElement;

  const tel = new Tel({ defaultCountry: "GB" });
</script>

<label>
  Phone number
  <div>
    <select
      bind:value={tel.country}
      onchange={() => {
        // Focus the input when the country is selected
        input?.focus();
      }}
    >
      <option value={null} disabled>🌍️ Select a country</option>
      {#each tel.countries as country}
        <option value={country.code}>
          {getFlagEmoji(country.code)}
          {country.name}
        </option>
      {/each}
    </select>
    <input bind:this={input} {...tel.props} />
  </div>
</label>

Still need more examples? Check out the demo website

Options

<script>
  import { Tel } from "svelte-tel";

  const tel = new Tel({
    // Required if using national format
    defaultCountry: "GB",
    // The default value of the input
    defaultValue: "447123456789",
    // Language to use for translations
		locale: "en",
    // The format to use when formatting the phone number
		format: "international";
		// Whether to hide the country code prefix in the input
		hideCallingCode: false;
		// Whether the country code is editable when in international format
		editableCountryCode: true;
		// The countries to exclude from the countries list
		excludeCountries: ["US"];
		// The countries to include in the countries list
		includeCountries: ["GB", "IE"];
  });
</script>

<!-- All options are $state() runes, so you can bind or change them after initialization -->
<input type="checkbox" bind:checked={tel.hideCallingCode} />

Contributing

I'm open to contributions, but I'm not sure how much more I want to add to this library. If you have a feature request, feel free to open an issue and we can discuss it. If you see a bug (most likely you will), please open an issue or a PR and I'll take a look.