### patterns example output
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the masked value for the patterns example. Input '789HelloWorld' becomes '(Hel-loW)'.
```text
Input value: 789HelloWorld
Masked value: (Hel-loW)
```
--------------------------------
### Install ngx-mask for Angular 15
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Install ngx-mask version 15.2.3 for Angular 15.x.x projects using npm or bun.
```bash
# Angular 15.x.x
$ npm install ngx-mask@15.2.3 # Using npm
$ bun add ngx-mask@15.2.3 # Using bun
```
--------------------------------
### Install ngx-mask with npm or bun for Angular 17+
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Install the latest ngx-mask package for Angular 17 and above. Use either npm or bun; both work equally well.
```bash
# For Angular 17 and above
$ npm install ngx-mask # Using npm
$ bun add ngx-mask # Using bun
```
--------------------------------
### Install ngx-mask for Angular 16
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Install ngx-mask version 16.4.2 for Angular 16.x.x projects using npm or bun.
```bash
# Angular 16.x.x
$ npm install ngx-mask@16.4.2 # Using npm
$ bun add ngx-mask@16.4.2 # Using bun
```
--------------------------------
### Thousand separator with different separators and precision
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows four input examples with different thousandSeparator and precision settings.
```html
```
--------------------------------
### leadZero masked value examples
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows how leadZero adds trailing zeros to the masked value.
```text
Input value: 12
Masked value: 12.00
Input value: 12.1
Masked value: 12.10
```
--------------------------------
### Install ngx-mask for Angular 14
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Install ngx-mask version 14.3.3 for Angular 14.x.x projects using npm or bun.
```bash
# Angular 14.x.x
$ npm install ngx-mask@14.3.3 # Using npm
$ bun add ngx-mask@14.3.3 # Using bun
```
--------------------------------
### specialCharacters example output
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the masked value for the specialCharacters example. Input '789-874.98' becomes '[78]\[987]'.
```text
Input value: 789-874.98
Masked value: [78]\[987]
```
--------------------------------
### Thousand separator masked value examples
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows how different input values are masked with separator.2 and various thousand separators.
```text
Input value: 1234.56
Masked value: 1 234.56
Input value: 1234,56
Masked value: 1.234,56
Input value: 1234.56
Masked value: 1,234.56
```
--------------------------------
### allowNegativeNumbers example output
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the model value when allowNegativeNumbers is true. Input '-10,000.45' becomes '-10000.45' in the model.
```text
Input value: -10,000.45
Model value: -10000.45
```
--------------------------------
### Install ngx-mask for Angular 13 or 12
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Install ngx-mask version 13.2.2 for Angular 13.x.x or 12.x.x projects using npm or bun.
```bash
# Angular 13.x.x or 12.x.x
$ npm install ngx-mask@13.2.2 # Using npm
$ bun add ngx-mask@13.2.2 # Using bun
```
--------------------------------
### Bootstrap with custom config using provideEnvironmentNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Passes a Partial to provideEnvironmentNgxMask for application-wide overrides. The example sets validation to false.
```typescript
import { NgxMaskConfig } from 'ngx-mask';
const maskConfig: Partial = { validation: false };
bootstrapApplication(AppComponent, { providers: [provideEnvironmentNgxMask(maskConfig)] }).catch(
(err) => console.error(err)
);
```
--------------------------------
### dropSpecialCharacters example output
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the model value when dropSpecialCharacters is false. Input '789-874.98' remains '789-874.98' in the model.
```text
Input value: 789-874.98
Model value: 789-874.98
```
--------------------------------
### Multi-mask with CPF/CNPJ
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Allows multiple masks in one expression using '||'. Example for CPF or CNPJ.
```html
```
--------------------------------
### placeHolderCharacter usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Customizes the placeholder character when showMaskTyped is enabled. The example uses '*' as the placeholder.
```html
```
--------------------------------
### separatorLimit masked value example
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows how separatorLimit truncates digits before the decimal point.
```text
Input value: 12345678,56
Masked value: 1.234,56
```
--------------------------------
### NgModule-based app setup with provideEnvironmentNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Imports NgxMaskDirective and NgxMaskPipe into an NgModule and registers provideEnvironmentNgxMask in providers. Exports the directive and pipe for use across the module.
```typescript
import { NgxMaskDirective, NgxMaskPipe, provideEnvironmentNgxMask } from 'ngx-mask';
@NgModule({
imports: [NgxMaskDirective, NgxMaskPipe],
exports: [NgxMaskDirective, NgxMaskPipe],
providers: [provideEnvironmentNgxMask()],
})
export class AppModule {}
```
--------------------------------
### showMaskTyped usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the mask while typing. The example uses prefix '+7' and mask '(000) 000-0000' with showMaskTyped set to true.
```html
```
--------------------------------
### suffix usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Adds a suffix to the masked value. The example uses suffix '$' with mask '0000'.
```html
```
--------------------------------
### defaultValueOnBlur output example
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the displayed and model values after the user clears the input and blurs with defaultValueOnBlur="0".
```text
User clears the input and blurs
Displayed value: 0
Model value: 0
```
--------------------------------
### Repeat mask usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Use brackets in the mask pattern to repeat a character. The example repeats 'A' four times.
```html
```
--------------------------------
### maskFilled event
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Triggers maskFilled event when mask is filled. Example uses mask '0000' and calls maskFilled() method.
```html
```
--------------------------------
### Thousand separator with separatorLimit
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Limits the number of digits before the decimal point. Example uses separatorLimit="1000".
```html
```
--------------------------------
### prefix usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Adds a prefix to the masked value. The example uses prefix '+7' with mask '(000) 000 00 00'.
```html
```
--------------------------------
### allowNegativeNumbers usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Allows negative numbers in the mask. The example uses mask 'separator.2' with allowNegativeNumbers set to true.
```html
```
--------------------------------
### Thousand separator precision limiting examples
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows how limiting decimal precision affects masked values. 2 is useful for currency; 0 prevents decimals completely.
```text
Input value: 1234,56
Masked value: 1.234,56
Input value: 1234.56
Masked value: 1,234.56
Input value: 1234,56
Masked value: 1.234
Input value: 1234.56
Masked value: 1,234
```
--------------------------------
### leadZeroDateTime with time mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
When leadZeroDateTime is true, skipped time symbols are replaced by '0'. Example shows input '777' masked as '07:07:07'.
```html
```
```text
Input value: 777
Masked value: 07:07:07
```
--------------------------------
### leadZeroDateTime with date mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
When leadZeroDateTime is true, skipped date/time symbols are replaced by '0'. Default is false. Example shows input '422020' masked as '04/02/2020'.
```html
```
```text
Input value: 422020
Masked value: 04/02/2020
```
--------------------------------
### Multi-mask with digits or letters
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Allows multiple masks in one expression using '||'. Example for two digits or two letters.
```html
```
--------------------------------
### Multi-mask with phone numbers
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Allows multiple masks in one expression using '||'. Example for phone numbers with or without area code.
```html
```
--------------------------------
### dropSpecialCharacters usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Disables dropping special characters from the model. Default is true, but setting to false keeps them. The example uses mask '000-000.00'.
```html
```
--------------------------------
### Secure input mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Hides symbols in input field while getting actual value in formcontrol. Uses [hiddenInput]="true" and mask 'XXX/X0/0000'.
```html
```
--------------------------------
### specialCharacters usage with mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Defines custom special characters for the mask. When overriding, all default special characters are not included. The example sets '[' , ']' and '\' as special characters and uses mask '[00]\[000]'.
```html
```
--------------------------------
### Mask pipe with config options
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Pass configuration options like thousandSeparator and suffix to the mask pipe.
```html
{{value | mask: 'separator': { thousandSeparator: ',', suffix: ' sm' } }}
```
--------------------------------
### instantPrefix usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Controls prefix display behavior. When instantPrefix is false, the prefix is only visible when a value is present; when true, it is displayed even if the model is empty.
```html
```
--------------------------------
### Bootstrap with default config using provideEnvironmentNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Registers ngx-mask application-wide with default options in a standalone Angular app. Call once in bootstrapApplication.
```typescript
bootstrapApplication(AppComponent, { providers: [provideEnvironmentNgxMask()] }).catch((err) =>
console.error(err)
);
```
--------------------------------
### Standalone app config with provideEnvironmentNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Register application-wide mask configuration in app.config.ts using provideEnvironmentNgxMask.
```typescript
// app.config.ts
import { provideEnvironmentNgxMask } from 'ngx-mask';
export const appConfig: ApplicationConfig = {
providers: [provideEnvironmentNgxMask({ validation: false })],
};
```
--------------------------------
### Pipe configuration with per-usage overrides
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Pass configuration overrides as the second argument to the mask pipe.
```html
{{ value | mask: 'separator' : { thousandSeparator: ',', suffix: ' sm' } }}
```
--------------------------------
### Migrating from NgxMaskModule to provideEnvironmentNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Shows the before/after migration from NgxMaskModule.forRoot() (ngx-mask ≤ 14) to the current standalone directive and provider. The before block uses NgxMaskModule.forRoot(maskConfig); the after block imports NgxMaskDirective and calls provideEnvironmentNgxMask(maskConfig).
```typescript
// Before (ngx-mask <= 14)
@NgModule({ imports: [NgxMaskModule.forRoot(maskConfig)] })
export class AppModule {}
// After (current ngx-mask)
@NgModule({
imports: [NgxMaskDirective],
providers: [provideEnvironmentNgxMask(maskConfig)],
})
export class AppModule {}
```
--------------------------------
### Enable typeFromDecimals application-wide via provider config
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Sets typeFromDecimals globally through provideNgxMask. The directive input wins when both are set.
```typescript
provideNgxMask({ typeFromDecimals: true });
```
--------------------------------
### Thousand separator with leadZero
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Adds zeros to the model at the end when leadZero is true.
```html
```
--------------------------------
### Basic mask directive usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Use the mask attribute with a literal mask string. The mask defines the input format.
```html
```
--------------------------------
### defaultValueOnBlur with showMaskTyped output
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows the displayed and model values after blurring the empty input with showMaskTyped and defaultValueOnBlur="9".
```text
User blurs the empty input
Displayed value: 9___
Model value: 9
```
--------------------------------
### defaultValueOnBlur with showMaskTyped
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
With showMaskTyped, the default fills the leading mask slots and the placeholder skeleton covers the rest.
```html
```
--------------------------------
### Per-component override with provideNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Override mask configuration for a component subtree using provideNgxMask.
```typescript
import { NgxMaskDirective, provideNgxMask } from 'ngx-mask';
@Component({
imports: [NgxMaskDirective],
providers: [provideNgxMask({ thousandSeparator: ',' })],
template: ``,
})
export class PriceInputComponent {}
```
--------------------------------
### Custom mask aliases usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
References custom aliases in mask input. Aliases are resolved at DI-config level and are static per injector.
```html
```
--------------------------------
### typeFromDecimals usage in HTML input
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Enables banking typing mode for separator masks with fixed precision. Typing digits fills from the decimal end; backspace shifts digits right. Works with thousandSeparator, prefix/suffix, allowNegativeNumbers, and separatorLimit. Default is false.
```html
```
--------------------------------
### Pipe with mask expression and custom Pattern
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Pass an array of expression and custom Pattern to the pipe. The pattern object defines a custom pattern for the mask expression.
```html
{{phone | mask: customMask}}
```
--------------------------------
### Thousand separator default usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Divides input by thousands with a space separator by default.
```html
```
--------------------------------
### patterns usage with customPatterns
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Uses a custom pattern object defined in the component. The mask '(000-000)' is applied with the custom patterns.
```html
```
--------------------------------
### Thousand separator with dot
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Uses a dot as the thousand separator.
```html
```
--------------------------------
### Custom pattern with reserved symbol *
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Shows a mask using the reserved '*' character for variable-length digits. The '*' is reserved and should not be used in custom patterns.
```html
```
--------------------------------
### Custom pattern definition with symbol
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Defines a custom pattern for the character 'B' with a regular expression matching digits and a symbol 'X' to be rendered in the input field.
```typescript
pattern = {
B: {
pattern: new RegExp('\\d'),
symbol: 'X',
},
};
```
--------------------------------
### Mask pipe usage
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Apply a mask to a value in a template using the mask pipe.
```html
{{phone | mask: '(000) 000-0000'}}
```
--------------------------------
### Percent validation mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates input for percents using mask 'percent' with suffix '%'. Also works with decimal markers like [decimalMarker]="['.', ',']".
```html
```
--------------------------------
### Conditional defaults with inputTransformFn and outputTransformFn
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Programmatic alternative to defaultValueOnBlur for conditional or computed defaults. The outputTransformFn never emits an empty value; the inputTransformFn renders empty incoming model values as '0'.
```typescript
// Model side: never emit an empty value
public outputTransformFn = (value: string | number | undefined | null) => (value === '' || value == null ? 0 : value);
// View side: render empty incoming model values as '0'
public inputTransformFn = (value: unknown) => (value === '' || value == null ? '0' : (value as string | number));
```
--------------------------------
### Feature-level config with provideNgxMask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/README.md
Registers ngx-mask for a standalone component's injector subtree using provideNgxMask. Import NgxMaskDirective in the component's imports.
```typescript
@Component({
selector: 'my-feature',
standalone: true,
imports: [NgxMaskDirective],
providers: [provideNgxMask()],
})
export class MyFeatureComponent {}
```
--------------------------------
### Secure date input mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Conceals day and month tokens while keeping year visible. Uses [hiddenInput]="true" and mask 'd0/M0/0000'.
```html
```
--------------------------------
### IP valid mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates IP address input using mask 'IP'.
```html
```
--------------------------------
### defaultValueOnBlur usage with separator mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Writes the given raw value through the mask pipeline on blur when the unmasked value is empty. The display shows the masked default, the model receives the usual output, and the write does not mark the form dirty. Default is null.
```html
```
--------------------------------
### customPatterns definition in component
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Defines a custom pattern for the digit '0' using a regular expression that matches letters. This is used with the patterns input.
```typescript
public customPatterns = { '0': { pattern: new RegExp('\[a-zA-Z\]')} };
```
--------------------------------
### Custom mask aliases configuration
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Defines custom named masks in config using maskAliases. Aliases are resolved before other mask processing and can expand to multi-mask expressions. Keys must be UPPER_SNAKE and not shadow built-in tokens.
```typescript
provideNgxMask({
maskAliases: {
PHONE_BR: '(00) 00000-0000',
MY_DOC: '000-AAA||0000-AAA',
},
});
```
--------------------------------
### Time validation mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates input as 24-hour format using mask 'Hh:m0:s0'.
```html
```
--------------------------------
### Thousand separator with decimals
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Adds decimal precision to the separator mask by appending '.N' to the mask.
```html
```
--------------------------------
### Date validation mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates date input using mask 'd0/M0/0000'.
```html
```
--------------------------------
### Component using NgxMaskDirective
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Import NgxMaskDirective in a component to use the mask directive.
```typescript
// any component that uses the mask
import { NgxMaskDirective } from 'ngx-mask';
@Component({
imports: [NgxMaskDirective],
template: ``,
})
export class MyComponent {}
```
--------------------------------
### Custom pattern definition for pipe
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Defines the customMask array and pattern object used with the pipe. The pattern defines a 'P' pattern matching a digit.
```typescript
customMask: [string, pattern];
pattern = {
P: {
pattern: new RegExp('\\d'),
},
};
this.customMask = ['PPP-PPP', this.pattern];
```
--------------------------------
### FormControl validation mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates formControl with mask '00 00' and [validation]="true". Default validation is true.
```html
```
--------------------------------
### Mask directive with property binding
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Bind the mask attribute to a component property using Angular property binding.
```html
" />
```
--------------------------------
### CPF_CNPJ valid mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates CPF or CNPJ input using mask 'CPF_CNPJ'.
```html
```
--------------------------------
### CPF_CNPJ_ALPHA valid mask
Source: https://github.com/nepipenkoigor/ngx-mask/blob/develop/USAGE.md
Validates CPF or CNPJ with alpha characters using mask 'CPF_CNPJ_ALPHA'.
```html
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.