← All pipes
Numbers

clamp

Constrain numeric display values to explicit bounds.

Use it in your component

Standalone component
import { Component } from '@angular/core';
import { ClampPipe } from 'extra-pipe';

@Component({
  standalone: true,
  imports: [ClampPipe],
  template: `{{ 120 | clamp: 0: 100 }}`,
})
export class ExampleComponent {

}

Template
{{ 120 | clamp: 0: 100 }}

Try it live.

The output below runs the packed library. Edit data, not code.

Use double quotes for text, or a number, array, object or null.
Ordered parameters: minimum, maximum. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = 120;
readonly parameter0 = 0;
readonly parameter1 = 100;
{{ value | clamp: parameter0: parameter1 }}

Rendered output

100