Open In App

Angular PrimeNG Form ColorPicker Styling Component

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see the Angular PrimeNG Form ColorPicker Styling Component.

The ColorPicker Component is used to make a component in which users can select colors. The Styling Component helps to make the interactive Form ColorPicker by implementing the different stylings provided by Angular PrimeNG.



Angular PrimeNG Form ColorPicker Styling Component: These styling components are described below:

 



Syntax:

<p-colorPicker [(ngModel)]="..." 
               [inline]="true">
</p-colorPicker>

Creating Angular application & module installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: It will look like the following:

 

ng serve --save

Example 1: This example illustrates the Angular PrimeNG Form ColorPicker Styling.




<div style="width: 80%;">
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
    <h2>
        Angular PrimeNG Form ColorPicker Styling Component
    </h2>
    <p-colorPicker [(ngModel)]="selectColor" 
                   [inline]="true">
    </p-colorPicker>
</div>




:host ::ng-deep  .p-colorpicker-hue {
  background:red !important;
}




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.css"]
})
  
export class AppComponent {
    selectColor: string = "";
}




import { NgModule } from "@angular/core";
import { BrowserModule }
    from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ColorPickerModule }
    from "primeng/colorpicker";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        FormsModule,
        ColorPickerModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule { }

Output:

 

Example 2: In this example, we will learn about another example of Angular PrimeNG Form ColorPicker Styling.




<div style="width:80%">
    <h1 style="color:green">
          GeeksforGeeks
      </h1>
    <h2>
          Angular PrimeNG Form 
          ColorPicker Styling Component.
      </h2>
    <p-colorPicker [inline]="false" 
                   [(ngModel)]="gfg">  
    </p-colorPicker>
</div>




:host ::ng-deep .p-colorpicker {
    background: red !important;
}
  
:host ::ng-deep .p-colorpicker-overlay {
    background: red !important;
}
  
:host ::ng-deep .p-colorpicker-hue {
    background: white !important;
}




import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.css"]
})
  
export class AppComponent {
    gfg: string = "#05f211";
}




import { NgModule } from "@angular/core";
import { BrowserModule } 
    from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule }
    from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ColorPickerModule } 
    from "primeng/colorpicker";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        FormsModule,
        ColorPickerModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
  
export class AppModule { }

Output:

 

Reference: https://primefaces.org/primeng/colorpicker


Article Tags :