@angular-slider/ngx-slider

中文文档
22.0.0发布于 2026/06/17MITTypeScriptES Module近 30 天下载 38.5万

Self-contained, mobile friendly slider component for Angular based on angularjs-slider

原始使用文档
文档目录15 节
  1. Dependencies
  2. Demos
  3. Installation
  4. Sample usage
  5. Documentation
  6. Styling
  7. Animations
  8. Keyboard Shortcuts
  9. Tooltips
  10. Known Issues
  11. Bugs
  12. Changelog
  13. Developer information
  14. License
  15. Upgrading

ngx-slider

npm version

Website: https://angular-slider.github.io/ngx-slider/

Discord: https://discord.gg/DHsDghZRwZ

Self-contained, mobile friendly slider component for Angular based on angularjs-slider.

Dependencies

ngx-sliderAngularRxJSActively supported
2.0.x6.x - 12.x6.xNo
13.x13.x6.xNo
14.x14.x6.xNo
15.x15.x7.xNo
16.x16.x7.xNo
17.x17.x7.xNo
18.x18.x7.xNo
19.x19.x7.xYes
20.x20.x7.xYes
21.x21.x7.xYes

Note: Like with Angular only the latest 3 versions are actively supported.

Demos

Installation

To add the slider to your Angular project:

npm install --save @angular-slider/ngx-slider

Once installed, add the slider to your app.module.ts:

import { NgxSliderModule } from '@angular-slider/ngx-slider';

...

@NgModule({
   ...
   imports: [
     ...
     NgxSliderModule,
    ...
   ],
   ...
})
export class AppModule {}

Sample usage

Now you can use the slider component in your app components, for example in app.component.ts:

import { Options } from '@angular-slider/ngx-slider';
...

@Component({...})
export class AppComponent {
  value: number = 100;
  options: Options = {
    floor: 0,
    ceil: 200
  };
}

And in template file app.component.html:

<ngx-slider [(value)]="value" [options]="options"></ngx-slider>

Documentation

Full API documentation is available on official website.

Styling

An overview of how to apply your own style to the slider is described in STYLING.md.

Animations

As of v1.2.0 the slider features CSS animations of slider movement. If you prefer the previous behaviour, without animations, you can set the flag animate: false in your slider options.

Keyboard Shortcuts

In addition to mouse/touch events, the slider can also be controlled through keyboard. The available shortcuts are:

  • right/up arrow - increase by single step,
  • left/down arrow - decrease by single step,
  • page up - increase by 10% of slider range,
  • page down - decrease by 10% of slider range,
  • home - move to minimum value,
  • end - move to maximum value.

Tooltips

The slider allows for customising how to implement tooltips. See TOOLTIPS.md for more information.

Known Issues

Before reporting a new bug, please look at KNOWN_ISSUES.md for a list of known problems and their workarounds. New bugs reports for these problems will not be accepted.

Bugs

You can report any bugs as Github issues.

Please describe the issue in detail pasting any relevant code, or preferrably a StackBlitz with reproduction of the problem by forking and editing this sample StackBlitz. Please also provide the version of NPM package you are using.

Changelog

For list of changes and bugfixes, see CHANGELOG.md.

Developer information

If you would like to contribute to the project, see DEVELOPERS.md.

License

The project is licensed under the MIT license.

Upgrading

For instructions on upgrading from previous (1.x) versions of the library, see UPGRADING.md.

版本与发布记录

@angular-slider/ngx-slider 共发布 19 个版本,首次发布于 2020/10/31;过去 12 个月发布了 2 个版本。

版本发布日期距今
22.0.0latest2026/06/174 个月前
21.0.02025/12/1310 个月前
20.0.02025/06/301.4 年前
19.0.02025/01/271.8 年前
18.0.02024/06/242 年前
17.0.22024/03/182 年前

关于 @angular-slider/ngx-slider 的常见问题

@angular-slider/ngx-slider 是什么?

Self-contained, mobile friendly slider component for Angular based on angularjs-slider

如何安装 @angular-slider/ngx-slider?

在项目目录运行 npm install @angular-slider/ngx-slider,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/core(^22.0.1)、@angular/common(^22.0.1)、@angular/forms(^22.0.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@angular-slider/ngx-slider 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@angular-slider/ngx-slider 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@angular-slider/ngx-slider 可以商用吗?

@angular-slider/ngx-slider 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@angular-slider/ngx-slider 的下载量有多少?

根据 npm 官方下载统计,@angular-slider/ngx-slider 在 2026/10/06 – 2026/11/04 这 30 天内被下载 384,662 次,日均约 12,822 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@angular-slider/ngx-slider 还在维护吗?

最新版本 22.0.0 发布于 2026/06/17(4 个月前);至今共发布 19 个版本,其中过去 12 个月发布了 2 个;首次发布于 2020/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。