Skip to content

MatthiasHuygelen/ngx-mask

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NGX-MASK

A powerful Angular directive for input masking with customizable patterns

Created with ❀️ by

JSDaddy

CI npm version npm downloads npm monthly downloads GitHub contributors GitHub Stars

Table of Contents

Features

NGX-MASK is a feature-rich input mask directive for Angular applications that provides:

🎯 Masking Patterns

β€’ Custom patterns & expressions

β€’ Multiple mask patterns (|)

β€’ Built-in common patterns

β€’ Prefix & suffix support

πŸ”’ Number Formatting

β€’ Thousand separators

β€’ Decimal markers

β€’ Negative numbers

β€’ Leading zeros

⚑ Input Control

β€’ Real-time validation

β€’ Clear on non-match

β€’ Show/hide mask typing

β€’ Keep character positions

πŸ“… Date & Time

β€’ Leading zero handling

β€’ AM/PM support

β€’ Custom separators

β€’ Multiple formats

πŸ› οΈ Customization

β€’ Custom placeholders

β€’ Special characters

β€’ Transform functions

β€’ Custom validation

πŸ“‹ Form Integration

β€’ Reactive Forms

β€’ ControlValueAccessor

β€’ Built-in validation

β€’ Standalone support

Demo

Check out our live documentation and examples

Installation

# For Angular 17 and above
$ npm install ngx-mask    # Using npm
$ bun add ngx-mask       # Using bun

# For specific Angular versions:
# Angular 16.x.x
$ npm install [email protected]    # Using npm
$ bun add [email protected]       # Using bun

# Angular 15.x.x
$ npm install [email protected]    # Using npm
$ bun add [email protected]       # Using bun

# Angular 14.x.x
$ npm install [email protected]    # Using npm
$ bun add [email protected]       # Using bun

# Angular 13.x.x or 12.x.x
$ npm install [email protected]    # Using npm
$ bun add [email protected]       # Using bun

Package Manager Note: You can use either npm or bun based on your preference. Both package managers will work equally well with ngx-mask.

Version Compatibility

NGX-MASK follows Angular's official support policy, supporting Active and LTS versions. Currently supported:

  • Angular 17 and newer (latest features and updates)
  • For older Angular versions, use the corresponding NGX-MASK version as specified above

Note: Versions for Angular older than v17 will not receive new features or updates.

Quick Start

For Angular 15+ (Standalone)

Application-wide Setup with Default Config

bootstrapApplication(AppComponent, { providers: [provideEnvironmentNgxMask()] }).catch((err) =>
    console.error(err)
);

With Custom Configuration

import { NgxMaskConfig } from 'ngx-mask';

const maskConfig: Partial<NgxMaskConfig> = { validation: false };

bootstrapApplication(AppComponent, { providers: [provideEnvironmentNgxMask(maskConfig)] }).catch(
    (err) => console.error(err)
);

Feature-level Configuration

@Component({
    selector: 'my-feature',
    standalone: true,
    imports: [NgxMaskDirective],
    providers: [provideNgxMask()],
})
export class MyFeatureComponent {}

For Angular < 15 (NgModule)

Application-wide Setup with Default Config

import { NgxMaskModule } from 'ngx-mask';

@NgModule({ imports: [NgxMaskModule.forRoot()] })
export class AppModule {}

With Custom Configuration

import { NgxMaskModule, NgxMaskConfig } from 'ngx-mask';

const maskConfig: Partial<NgxMaskConfig> = { validation: false };

@NgModule({ imports: [NgxMaskModule.forRoot(maskConfig)] })
export class AppModule {}

Feature-level Configuration

import { NgxMaskModule } from 'ngx-mask';

@NgModule({ imports: [NgxMaskModule.forChild()] })
export class FeatureModule {}

Related Projects

Check out other projects by JSDaddy:

Contributing

We welcome contributions! Please read our contributing guidelines to learn about our development process and how you can propose bugfixes and improvements.

About

Angular Plugin to make masks on form fields and html elements.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.4%
  • JavaScript 1.4%
  • HTML 1.1%
  • SCSS 0.1%