Open In App

Angular PrimeNG Knob 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 know how to use the Knob component in Angular PrimeNG.

Knob component: It is a form component that is used to define a dialer type knob that contains labels and some data values.



Properties:

Events:



 

Styling:

Creating Angular Application & module Installation :

Project Structure: After completion of the installation process, it will look like the following.

Example 1: In this step, we will see the basic example that illustrates the use of the knob component. 




<h2 style="color: green">GeeksforGeeks</h2>
<h5>PrimeNG Knob component</h5>
<div class="p-field p-col-12 p-md-4">
    
  <h4>Basic</h4>
  <p-knob
    [size]="150"
    [strokeWidth]="9"
    valueColor="green"
    rangeColor="navy">
  </p-knob>
    
  <h4>Disabled</h4>
  <p-knob
    [size]="150"
    [strokeWidth]="9"
    valueColor="Green"
    rangeColor="grey"
    [disabled]="true">
  </p-knob>
</div>




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 { KnobModule } from "primeng/knob";
  
@NgModule({
  imports: [BrowserModule, 
              BrowserAnimationsModule, 
            KnobModule, FormsModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

 

Output:

Example 2: In this example, we will know how to use the steps & stroke property in the knob component. 




<h2 style="color: green">GeeksforGeeks</h2>
<h5>PrimeNG Knob component</h5>
  
<div class="p-field p-col-12 p-md-4">
  <h5>Step</h5>
  <p-knob
    [size]="150"
    [strokeWidth]="9"
    valueColor="Green"
    rangeColor="Blue"
    [step]="10">
  </p-knob>
</div>
  
<div class="p-field p-col-12 p-md-4">
  <h5>Stroke</h5>
  <p-knob
    [size]="150"
    [strokeWidth]="9"
    valueColor="Green"
    rangeColor="Blue"
    [step]="10"
    [strokeWidth]="5">
  </p-knob>
</div>




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 { KnobModule } from "primeng/knob";
  
@NgModule({
  imports: [BrowserModule, 
              BrowserAnimationsModule, 
            KnobModule, FormsModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Output:

Reference: https://primefaces.org/primeng/showcase/#/knob


Article Tags :