Svelte Input Mask

screenshot of Svelte Input Mask
svelte

Svelte Input Mask

Input masking component for Svelte with simple API and rich customization

Overview:

This project provides a simple API for masking input fields such as credit card numbers, phone numbers, dates, birthdays, and custom masks. It offers rich customization options to suit different use cases. The project also includes demos that demonstrate its functionality.

Features:

  • Mask various types of input: Supports masking for credit card numbers, phone numbers, dates, birthdays, and custom masks.
  • Customizable prefixes and country codes: Can change prefixes and country codes for phone numbers similar to credit card examples.
  • Flexible formatting options: Allows users to define their own mask strings or use a predefined mask format.
  • Control over input value: Users have control over the value of the input field, which is processed to match the specified mask.
  • Default value option: Supports setting a default value for the input field during the first render.
  • Show or hide mask: Users can choose to show or hide the mask based on the data entered in the input field.
  • Rich customization options: Offers a range of props to customize the mask input behavior.

Installation:

To use this project, follow the steps below:

  1. Install the project using npm or yarn:

    If using npm, run the following command:

    npm install masked-input
    

    If using yarn, run the following command:

    yarn add masked-input
    
  2. Import the MaskInput component into your project:

    import { MaskInput } from "masked-input";
    
  3. Use the MaskInput component in your code:

    For example, to create a masked input for a credit card number:

    <MaskInput mask="0000-0000-0000-0000" />
    
  4. Add event listeners as needed.

Congratulations! You have successfully created your first masked input.

For more use cases and examples, refer to the demos.

Summary:

This project provides an easy-to-use API for creating masked input fields. It supports various types of input such as credit card numbers, phone numbers, dates, birthdays, and custom masks. The project offers rich customization options with props to control the input value, default value, mask string, mask character, mask format, and more. With its flexibility and simplicity, the masked-input project is a valuable tool for developers needing masked input functionality in their web applications.

svelte
Svelte

Svelte is a modern front-end framework that compiles your code at build time, resulting in smaller and faster applications. It uses a reactive approach to update the DOM, allowing for high performance and a smoother user experience.