Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ngx-loader-indicator

JsDaddy3.5kMIT19.0.1TypeScript support: included

The best directive without wrapping your element to additional component

ngx-loader-indicator, ngx-loader, ngx, ngx-spinner, ngx-loader-spinner, angular, jsdaddy

readme

NGX LOADER INDICATOR

NGX LOADER INDICATOR is the best directive to have loader without wrapping your element to additional component

CI npm npm downloads

npm

GitHub contributors

GitHub stars

You can also try our NGX MASK check it. You can also try our NGX COPYPASTE check it.

You can try live demo with examples.

Installing

npm

$ npm install --save ngx-loader-indicator

bun

$ bun install --save ngx-loader-indicator

Quickstart if ngx-loader-indicator version >= 15.0.0

Pay attention this version works for angular >= 14.0.0

Configure for application with provideEnvironmentNgxLoaderIndicator

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

or configure for feature with provideNgxLoaderIndicator and import standalone directive NgxLoaderIndicatorDirective

@Component({
    selector: 'my-feature',
    templateUrl: './my-feature.component.html',
    styleUrls: ['./my-feature.component.css'],
    standalone: true,
    imports: [NgxLoaderIndicatorDirective, (...)],
    providers: [
        (...)
        provideNgxLoaderIndicator({
            img: 'https://avatars2.githubusercontent.com/u/32452610?s=200&v=4',
            loaderStyles: {
                background: 'rgba(255, 255, 255, 0.8)',
            },
            imgStyles: {
                width: '50px',
                background: 'yellow',
            },
            rotate: {
                duration: 5000,
            },
        }),
    ],
})
export class MyFeatureComponent {}

Quickstart if ngx-loader-indicator version < 15.0.0

Pay attention this version works for angular < 12.0.0

Import module in needed module.

import {NgxLoaderIndicatorModule} from 'ngx-loader-indicator'

(...)

@NgModule({
  (...)
  imports: [
    NgxLoaderIndicatorModule.forRoot(options)
  ]
  (...)
})

Usage

<div [ngxLoaderIndicator]="isLoading">Content</div>

Examples

<form (ngSubmit)="save(form.value)" [formGroup]="form" [ngxLoaderIndicator]="isLoading">
    <h2>Login</h2>
    <input matInput type="email" placeholder="Email" #email formControlName="email" />
    <input matInput type="password" placeholder="Password" #name formControlName="password" />
    <button mat-button [disabled]="form.invalid">Login</button>
</form>

Options

You can define your custom options

custom img (string) and colors

  {
    img: string,
    imgStyles: {
      width: string, // '30px'
      background: string, // 'yellow' or rgb(255, 255, 0)
    }
  }

custom wrapper layout colors

  {
    loaderStyles: {
      background: string,
    },
  }

animations options for image rotation

    rotate: {
      delay?: number;
      direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
      duration: number
      easing?: string;
      endDelay?: number;
      fill?: 'none' | 'forwards' | 'backwards' | 'both' | 'auto';
      id?: string;
      iterationStart?: number;
      iterations?: number;
    },

Usage

import {NgxLoaderIndicatorModule} from 'ngx-loader-indicator'

(...)

@NgModule({
  (...)
  imports: [
    NgxLoaderIndicatorModule.forRoot({
      img: 'https://avatars2.githubusercontent.com/u/32452610?s=200&v=4',
      loaderStyles: {
        background: 'rgba(255, 255, 255, 0.8)',
      },
      imgStyles: {
        width: '100px',
        background: 'yellow',
      },
      rotate: {
        duration: 5000
      },
    }),
  ]
  (...)
})

changelog

19.0.1(2025-04-30)

Feature

  • update dependencies

19.0.0(2024-11-21)

Feature

  • update ng 19.x

18.0.4(2024-10-25)

Feature

  • add tailwind
  • change interface to type, remove prefix "I"
  • update dependencies
  • add ESLint strict rules

17.3.2(2024-03-29)

Feature

  • change decorators to signals

17.0.0(2023-11-28)

Feature

  • update ng 17.x

16.0.1(2023-10-03)

Feature

  • update dependencies

16.0.0(2023-07-07)

Feature

  • update ng 16.x

15.0.0(2022-26-12)

Feature

  • update to ng15

[6.0.0 base functionality] (2018-05-17)

[6.1.0 base functionality] (2018-05-21)

Custom styles(background, color, size) for image and wrapper

Custom animations for image rotation