Open In App

Angular PrimeNG Form Inputtext Sizes Component

Last Updated : 26 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 learn how to use the InputText Sizes Component in Angular PrimeNG. Let’s learn about the properties, and syntaxes that will be used in the code.

The Inputtext Component is an element used for entering data created by inputText. There are 2 other sizes available in addition to the standard input; use p-inputtext-sm for a smaller input and p-inputtext-lg for a bigger one.

Syntax:

<input
    type="text"
    pInputText
    placeholder="...."
    class="...."
/>

Angular PrimeNG Form Inputtext Sizes Component properties:

  • disabled: We can set the input component to be disabled. It is of a boolean data type & the default value is false.
  • placeholder: It is used to set the Placeholder text for the input. It is of string data type, the default value is null.

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.

 

Steps to run the application: Run the below command to see the output

ng serve --open

Example 1: This is the basic example that shows how to use the Angular PrimeNG Form Inputtext Sizes Component.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Form Inputtext Sizes Component</h5>
 
<input type="text" pInputText
    placeholder="Small InputText"
    class="p-inputtext-sm"
/>
<br /><br />
<input type="number" pInputText
    placeholder="Large InputText"
    class="p-inputtext-lg"
/>


  • app.component.ts:

Javascript




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


  • app.module.ts:

Javascript




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 {InputTextModule} from 'primeng/inputtext';
import {ButtonModule} from 'primeng/button';
 
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        InputTextModule,
        ButtonModule,
        FormsModule
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
 
export class AppModule { }


Output:

 

Example 2: Sizing may be applied to a group by adding the class to a container element rather than duplicating the scale classes for each input, making it simpler for descendant inputs to have the same design. Below is an example where we will see the same.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Form Inputtext Sizes Component</h5>
 
<div class="p-inputtext-sm">
    <input type="text"
        pInputText placeholder="Small InputText"
    /><br /><br />
    <input type="number"
        pInputText placeholder="Small InputText"
    />
</div>
<br />
<div class="p-inputtext-lg">
    <input type="text"
        pInputText placeholder="Large InputText"
    /><br /><br />
    <input type="number"
        pInputText placeholder="Large InputText"
    />
</div>


  • app.component.ts:

Javascript




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


  • app.module.ts:

Javascript




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 {InputTextModule} from 'primeng/inputtext';
import {ButtonModule} from 'primeng/button';
 
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        InputTextModule,
        ButtonModule,
        FormsModule
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
 
export class AppModule { }


Output:

 

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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads