Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

ngx-custom-material-file-input

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-custom-material-file-input

File input management for Angular Material

latest
Source
npmnpm
Version
21.0.3
Version published
Weekly downloads
4.2K
45.09%
Maintainers
1
Weekly downloads
 
Created
Source

npm version npm Known Vulnerabilities

ngx-custom-material-file-input

This project is a copy of ngx-material-file-input, this was made from angular 14 as a new project, only what was necessary was added and is already updated.

Library VersionAngular Version
1.0.014.0.0
2.0.015.0.0
3.0.016.0.0
4.0.017.0.0
18.0.018.0.0

From now on, the package version will be the same as the Angular version so I don't have to update the table all the time.

  • Latest version is using Angular 21

From Angular 21 onwards, it is only supported as a standalone component.

material-file-input

This project provides :

  • ngx-mat-file-input component, to use inside Angular Material mat-form-field
  • a FileValidator with acceptedMimeTypes, to limit the format types using the mime types
  • a FileValidator with maxContentSize, to limit the file size
  • a FileValidator with minFileCount and maxFileCount, to limit the loaded files
  • a ByteFormatPipe to format the file size in a human-readable format
  • a previewUrls to receive the images/file as a url to show in a preview

For more code samples, have a look at the DEMO SITE or in the release notes.

Install

npm i ngx-custom-material-file-input

API reference

MaterialFileInputModule

import { MaterialFileInputModule } from 'ngx-custom-material-file-input';

@NgModule({
  imports: [
    // the module for this lib
    MaterialFileInputModule
  ]
})

NGX_MAT_FILE_INPUT_CONFIG token (optional):

Change the unit of the ByteFormat pipe

export const config: FileInputConfig = {
  sizeUnit: "Octet",
};

// add with module injection
providers: [{ provide: NGX_MAT_FILE_INPUT_CONFIG, useValue: config }];

FileInputComponent

selector: <ngx-mat-file-input>

implements: MatFormFieldControl from Angular Material

Additionnal properties

NameDescriptionAdded in Version
@Input() valuePlaceholder: stringPlaceholder for file names, empty by defaultv1
@Input() multiple: booleanAllows multiple file inputs, false by defaultv1
@Input() autofilled: booleanWhether the input is currently in an autofilled state. If property is not present on the control it is assumed to be false.v1
@Input() accept: stringAny value that accept attribute can get. more about "accept"v1
@Input() checkDuplicates: booleanSkip duplicated files if the property is added, false by defaultv21
value: FileInputForm control valuev1
empty: booleanWhether the input is empty (no files) or notv1
clear(): (event?) => voidRemoves all files from the inputv1
previewUrls: string[]Contains a generate url in memory to show the previews of the filesv19
@Input() defaultIconBase64: stringSet the default icon for the previews of files that are not images, is a base64 string, example: data:image/svg+xml;base64,PHN2ZyB.....v19

ByteFormatPipe

Example

<span>{{ 104857600 | byteFormat }}</span>

Output: 100 MB

FileValidator

NameDescriptionError structureAdded in Version
maxContentSize(value: number): ValidatorFnLimit the total file(s) size to the given value{ actualSize: number, maxSize: number }v1
acceptedMimeTypes(value: string): ValidatorFnLimit the mime types valid to use given value{ validTypes: string }v18
minFileCount(value: number): ValidatorFnLimit the total of minimum file(s) loaded to the given value{ minCount: number, actualCount: number }v20
maxFileCount(value: number): ValidatorFnLimit the total of maximum file(s) loaded to the given value{ maxCount: number, actualCount: number }v20

Sponsored by: MyTalentAid

Keywords

angular

FAQs

Package last updated on 23 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts