Angular PrimeNG ProgressSpinner颜色
Angular PrimeNG是一个开源框架,拥有丰富的原生Angular UI组件,可用于出色的造型,该框架可用于制作响应式网站,非常方便。本文将向我们展示如何在Angular PrimeNG中使用ProgressSpinner Colors。我们还将了解代码中使用的属性及其语法。
ProgressSpinner组件用于制作一个说明进程状态的旋转器。关键帧动画可以被覆盖以修改喷丝板的颜色。
语法:
<p-progressSpinner
[style]="{...}"
strokeWidth="..."
styleClass="..."
fill="...">
</p-progressSpinner>
Angular PrimeNG ProgressSpinner颜色属性:
- strokeWidth: 它指定了圆圈笔触的宽度。它接受一个字符串数据类型作为输入,默认值为2。
- fill:它指定了圆的背景颜色。它是字符串数据类型,默认值为空。
- animationDuration。指定旋转动画的持续时间。它是字符串数据类型,默认值是2s。
创建Angular应用程序和模块安装。
第1步:使用以下命令创建一个Angular应用程序。
ng new appname
第2步:在创建你的项目文件夹即应用程序名称后,使用以下命令移动到它。
cd appname
第3步在你给定的目录中安装PrimeNG。
npm install primeng --save
npm install primeicons --save
项目结构:完成安装后,它将看起来像下面这样。
运行以下命令以查看输出:
ng serve --open
示例1:下面是说明使用Angular PrimeNG ProgressSpinner Colors的示例代码。
<div style="text-align: center">
<h2 style="color: green">
GeeksforGeeks
</h2>
<h5>Angular PrimeNG ProgressSpinner Colors</h5>
<p-progressSpinner [style]=
"{ width: '100px', height: '100px'}"
strokeWidth="5"
styleClass="geek-spinner"
fill="yellow">
</p-progressSpinner>
</div>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['app.component.scss']
})
export class AppComponent { }
:host ::ng-deep .geek-spinner .p-progress-spinner-circle {
animation: geek 8s ease-in-out infinite;
}
@keyframes geek {
100%,
0% {
stroke: #008744;
}
40% {
stroke: #ffa700;
}
66% {
stroke: #0057e7;
}
80%,
90% {
stroke: #d62d20;
}
}
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ProgressSpinnerModule }
from 'primeng/progressspinner';
@NgModule({
imports: [
BrowserAnimationsModule,
ProgressSpinnerModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
输出:
示例2:下面是另一个示例代码,说明了Angular PrimeNG ProgressSpinner Colors使用一些其他的自定义属性值。
<div style="text-align: center">
<h2 style="color: green">
GeeksforGeeks
</h2>
<h5>Angular PrimeNG ProgressSpinner Colors</h5>
<p-progressSpinner [style]=
"{width: '75px', height: '75px'}"
strokeWidth="10"
styleClass="geek-spinner" fill="black">
</p-progressSpinner>
</div>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['app.component.scss']
})
export class AppComponent { }
:host ::ng-deep .geek-spinner .p-progress-spinner-circle {
animation: geek 3s ease-in-out infinite;
}
@keyframes geek {
0% {
stroke: #008744;
}
50% {
stroke: #00ffc8;
}
80% {
stroke: #e7009a;
}
100% {
stroke: #444242;
}
}
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ProgressSpinnerModule }
from 'primeng/progressspinner';
@NgModule({
imports: [
BrowserAnimationsModule,
ProgressSpinnerModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
输出: