@dhutaryan/ngx-mat-timepicker

中文文档
22.0.0发布于 2026/09/15MITTypeScriptES Module近 30 天下载 1.8万

Angular timepicker to add time which is based on material design and Angular material.

原始使用文档
文档目录9 节
  1. Versions
  2. Documentation
  3. Installation
  4. Getting started
  5. Adapter
  6. Theming
  7. Usage
  8. Locale
  9. License

ngx-mat-timepicker

npm code factor license npm bundle size

The timepicker module using Angular material.

Versions

mat-timepickerAngular
22.x.x>=22.0.0
21.x.x>=21.0.0
20.1.x>=20.2.0
20.0.x>=20.0.0
19.x.x>=19.0.0
18.x.x>=18.0.0
17.x.x^17.0.0
16.x.x^16.0.0
15.x.x^15.0.0
14.x.x^14.0.0
13.x.x>=13.0.0 && <15.0.0
12.x.x>=12.0.0 && <15.0.0

Documentation

Check out the documentation.

Installation

You have to install the Angular Material and set it up. Learn more about the setup.

Install the library:

$ npm install --save @dhutaryan/ngx-mat-timepicker

or

$ yarn add @dhutaryan/ngx-mat-timepicker

Getting started

Import MatTimepickerModule to your project.

import { MatTimepickerModule } from '@dhutaryan/ngx-mat-timepicker';

@NgModule({
  imports: [
    // ...
    MatTimepickerModule,
    // ...
  ],
})
export class MyModule {}

Adapter

Add a timepicker adapter.

import {
  MatTimepickerModule,
  provideNativeDateTimeAdapter,
} from '@dhutaryan/ngx-mat-timepicker';

@NgModule({
  imports: [
    // ...
    MatTimepickerModule,
    // ...
  ],
  providers: [provideNativeDateTimeAdapter()],
})
export class MyModule {}

or create your own

import { MatTimepickerModule } from '@dhutaryan/ngx-mat-timepicker';

@NgModule({
  imports: [
    // ...
    MatTimepickerModule,
    // ...
  ],
  providers: [{ provide: TimeAdapter, useClass: MyTimeAdapter }],
})
export class MyModule {}

Theming

Then you have to define a theme. More details about theming.

@use '@dhutaryan/ngx-mat-timepicker' as mat-timepicker;

// timepicker uses these component
@include mat.form-field-theme(theme.$ngx-mat-timepicker-theme);
@include mat.input-theme(theme.$ngx-mat-timepicker-theme);
@include mat.button-theme(theme.$ngx-mat-timepicker-theme);
@include mat.fab-theme(theme.$ngx-mat-timepicker-theme);
@include mat.icon-button-theme(theme.$ngx-mat-timepicker-theme);
@include mat.divider-theme(theme.$ngx-mat-timepicker-theme);

// timepicker theme
@include mat-timepicker.timepicker-theme($theme);

// if you want to support color attribute in M3 add compatibility mixin
@include mat.color-variants-backwards-compatibility($my-theme);

You can also use mat.theme mixin instead.

Usage

<mat-form-field>
  <input type="text" matInput [matTimepicker]="timepicker" />
  <mat-timepicker-toggle matSuffix [for]="timepicker"></mat-timepicker-toggle>
  <mat-timepicker #timepicker></mat-timepicker>
</mat-form-field>

Locale

Default locale is en-US. You can set your locale as:

import { NgModule } from '@angular/core';
import { MAT_TIME_LOCALE } from '@dhutaryan/ngx-mat-timepicker';

@NgModule({
  imports: [
    // ...
  ],
  providers: [{ provide: MAT_TIME_LOCALE, useValue: 'en-GB' }],
})
export class MyModule {}

License

MIT

版本与发布记录

@dhutaryan/ngx-mat-timepicker 共发布 83 个版本,首次发布于 2023/04/26;过去 12 个月发布了 4 个版本。

版本发布日期距今
22.0.0latest2026/09/151 个月前
20.2.02026/02/099 个月前
21.0.02026/02/099 个月前
20.1.02025/12/0711 个月前
20.0.02025/07/041.4 年前
19.2.02025/06/091.4 年前

其他发布通道:previous → 15.0.2,latest-v12 → 12.5.4,latest-v13 → 13.2.4,latest-v14 → 14.2.4,latest-v15 → 15.4.3,latest-v16 → 16.4.3。

关于 @dhutaryan/ngx-mat-timepicker 的常见问题

@dhutaryan/ngx-mat-timepicker 是什么?

Angular timepicker to add time which is based on material design and Angular material.

如何安装 @dhutaryan/ngx-mat-timepicker?

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

@dhutaryan/ngx-mat-timepicker 支持 TypeScript 吗?

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

@dhutaryan/ngx-mat-timepicker 支持 ESM 还是 CommonJS?

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

@dhutaryan/ngx-mat-timepicker 可以商用吗?

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

@dhutaryan/ngx-mat-timepicker 的下载量有多少?

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

@dhutaryan/ngx-mat-timepicker 还在维护吗?

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