Angular PrimeNG InputText Component

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 InputText component in angular primeNG. Let’s learn about the properties, styling & their syntaxes that will be used in the code. 
InputTextArea component: It is an element that is used to make a text field with multi-line input support.
Properties:
disabled: We can set the input component to be disabled. It is of a boolean data type & the default value is false.
Styling:
p-inputtext: It is a directive & applied to the text input field.
<input type="text" pInputText />
 
Model Binding: ngModel directive is used to bind the model.
<input type="text" pInputText [(ngModel)]="property"/>
Size: In addition to the regular sizes, there are more than 2 sizes that are available, add p-inputtext-sm for small text input & add p-inputtext-lg for large text input. These classes must be used to change the size of the particular input field.For smaller input text
<input type="text" pInputText class="p-inputtext-sm">
For larger input text
<input type="text" pInputText class="p-inputtext-lg"> 
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: It will look like the following.
 
Example 1: This is the basic example that shows how to use InputText component 
app.component.html
<h2>GeeksforGeeks</h2><h5>PrimeNG InputText component</h5><div class="sizes">  <input    type="text"    class="p-inputtext-lg"    placeholder="Input text here"    pInputText/></div>
app.module.ts
import { NgModule } from "@angular/core";import { BrowserModule } from "@angular/platform-browser";import { BrowserAnimationsModule } from "@angular/platform-browser/animations";  import { AppComponent } from "./app.component";  import { InputTextModule } from "primeng/inputtext";  @NgModule({  imports: [BrowserModule, BrowserAnimationsModule, InputTextModule],  declarations: [AppComponent],  bootstrap: [AppComponent],})export class AppModule {}
Output:
Example 2: In this example, we will know how to set the size of the InputText component. 
app.component.html
<h2>GeeksforGeeks</h2><h5>PrimeNG InputText component</h5><div class="sizes">  <input    type="text"    class="p-inputtext-sm"    placeholder="Input text here"    pInputText/>  <input type="text" placeholder="Input text here" pInputText />  <input    type="text"    class="p-inputtext-lg"    placeholder="Input text here"    pInputText/></div>
app.module.ts
import { NgModule } from '@angular/core';import { BrowserModule } from '@angular/platform-browser';import { BrowserAnimationsModule }     from '@angular/platform-browser/animations';  import { AppComponent } from './app.component';  import { InputTextModule } from 'primeng/inputtext';  @NgModule({  imports: [BrowserModule,               BrowserAnimationsModule,             InputTextModule],  declarations: [AppComponent],  bootstrap: [AppComponent]})export class AppModule {}
Output:
Reference: https://primefaces.org/primeng/showcase/#/inputtext
Angular-PrimeNG
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Routing in Angular 9/10
Angular PrimeNG Dropdown Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
How to create module with Routing in Angular 9 ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?