ngx-colors
#455a64
Slide-In animations & Default palette
#c2185b
Popup animations & Custom palette
ngx-colors is a colorpicker component of angular with a material design style, allows users to select a color via text input (hexadecimal, rgba, hsla), choosing a preset color from the palette, or a color picker using the Hue, Lightness, and Alpha sliders.
It is composed of two parts:npm install @angular/animations
npm install ngx-colors
import { NgxColorsModule } from 'ngx-colors';
@NgModule({
...
imports: [
...
NgxColorsModule
]
})
<ngx-colors ngx-colors-trigger [(ngModel)]="leftColor"></ngx-colors>
<mat-form-field>
<input matInput [(ngModel)]="leftColor">
</mat-form-field>
<form class="example-form">
<ngx-colors ngx-colors-trigger style="display: inline-block; margin:5px;" [formControl]="colorFormControl"></ngx-colors>
</form>
Value: {{ colorFormControl.value }}
Try it out here:
import { animate, style, transition, trigger } from "@angular/animations";
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-detect-change-example",
templateUrl: "./detect-change-example.component.html",
animations: [
trigger("inOutAnimation", [
transition(":enter", [
style({ background: "red" }),
animate("1s ease-out", style({})),
]),
]),
],
styleUrls: ["./detect-change-example.style.scss"],
})
export class DetectChangeExampleComponent {
constructor() {}
color = "#0070f3";
colorIndex = 0;
colors = ["#0070f3", "#00796B", "#D81B60", "#7986CB"];
logs: Array<Array<any>> = [];
public rotateColor(): void {
this.colorIndex = (this.colorIndex + 1) % this.colors.length;
this.color = this.colors[this.colorIndex];
}
public logEvent(event, trigger) {
this.logs.unshift([this.logs.length + 1, trigger, event]);
}
}