Angular PrimeNG Knob Component - GeeksforGeeks

19 Aug, 2021
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:
size: It is used to set the size of the component in pixels. It is of number data type, the default value is 100.
disabled: It specifies that the element should be disabled. It is of the boolean data type, the default value is false.
readonly: It is used to specify that the component cannot be edited. It is of the boolean data type, the default value is false.
min: It is used to set the minimum boundary value. It is of number data type, the default value is 0.
max: It is used to set the maximum boundary value. It is of number data type, the default value is 100.
step: It is used to set the step factor to increment/decrement the value. It is of number data type, the default value is null.
valueColor: It is used to set the background of the value. It is of string data type, the default value is null.
rangeColor: It is used to set the background color of the range. It is of number data type, the default value is null.
textColor: It is used to set the color of the value text. It is of number data type, the default value is null.
strokeWidth: It is used to set the width of the knob stroke. It is of number datatype, the default value is 14.
showValue: It is used to specify whether to show the value inside the knob. It is of the boolean datatype, the default value is true.
valueTemplate: It is used to set the template string of the value. It is of string data type, the default value is value.
style: It is used to set the Inline style of the element. It is of object data type, the default value is null.
styleClass: It is used to set the Style class of the element. It is of string data type, the default value is null.
Events:
onChange: It is a callback that is fired when the value changes.
 
Styling:
p-knob: It is a styling Container element.
p-knob-text: It is a styling Text element.
p-knob-value: It is a styling Value element.
p-knob-text: It is a styling Text element.
Creating Angular Application & module Installation :
Step 1: Create an Angular application using the following command.ng new appname
ng new appname
Step 2: After creating your project folder i.e. appname, move to it using the following command.cd appname
cd appname
Step 3: Install PrimeNG in your given directory.npm install primeng --save
npm install primeicons --save
npm install primeng --save
npm install primeicons --save
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. 
app.component.html
<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>
app.module.ts
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. 
app.component.html
<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>
app.module.ts
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
Angular-PrimeNG
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Angular Libraries For Web Developers
How to use <mat-chip-list> and <mat-chip> in Angular Material ?
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?