Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will see Angular PrimeNG Inplace Styling.
The Inplace component is used to provide an easy to do editing and display to the user. When the output of the Inplace component is clicked the content is revealed. There structural classes of the Inplace component are listed below.
Angular PrimeNG Inplace Styling Classes:
- p-inplace: It is the container element of the Inplace component.
- p-inplace-display: It is the container element of the Inplace display.
- p-inplace-content: It is the container element of the Inplace content.
Angular PrimeNG Inplace Styling Properties: There are no properties for PrimeNG Inplace Styling.
Syntax:
// File: app.component.html <p-inplace> <ng-template pTemplate="display"> ... </ng-template> <ng-template pTemplate="content"> ... </ng-template> </p-inplace> // File: app.component.css :host ::ng-deep .Styling-Class { // CSS }
Creating Angular Application and Installing the Module:
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: Finally, Install PrimeNG in your given directory.
npm install primeng --save npm install primeicons --save
Project Structure: The project Structure will look like this after following the above steps:
Example 1: In this example, we use the “p-inplace” styling class of the Inplace component to give it some padding and set the background color to green.
app.component.html:
< h2 style = "color: green;" >GeeksforGeeks</ h2 >
< h3 >Angular PrimeNG Inplace Styling</ h3 >
< p-inplace >
< ng-template pTemplate = "display" >
Click to see the Tags
</ ng-template >
< ng-template pTemplate = "content" >
< p-chip label = "Data Structures" ></ p-chip >
< p-chip label = "Algorithms" ></ p-chip >
< p-chip label = "Compiler Design" ></ p-chip >
</ ng-template >
</ p-inplace >
|
app.component.css:
:host ::ng-deep .p-inplace { padding : 20px ;
background-color : green ;
} |
app.component.ts:
import { Component } from "@angular/core" ;
@Component({ selector: "app-root" ,
templateUrl: "./app.component.html" ,
styleUrls: [ './app.component.css' ]
}) export class AppComponent { } |
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 { TableModule } from "primeng/table" ;
import { InplaceModule } from "primeng/inplace" ;
import { ChipModule } from "primeng/chip" ;
@NgModule({ imports: [
BrowserModule,
BrowserAnimationsModule,
InplaceModule,
FormsModule,
TableModule,
ChipModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
}) export class AppModule { } |
Output:
Example 2: In this example, we used the “p-inplace-display” and “p-inplace-content” styling classes to style the inplace component.
app.component.html:
< h2 style = "color: green;" >GeeksforGeeks</ h2 >
< h3 >Angular PrimeNG Inplace Styling</ h3 >
< p-inplace >
< ng-template pTemplate = "display" >
Reveal the Buttons
</ ng-template >
< ng-template pTemplate = "content" >
< button
pButton
label = "Normal Button"
class = "mr-4" >
</ button >
< button
pButton
label = "Danger Button"
class = "p-button-danger" >
</ button >
</ ng-template >
</ p-inplace >
|
app.component.css:
:host ::ng-deep .p-inplace { margin-top : 40px ;
} :host ::ng-deep .p-inplace-display { padding : 20px ;
border : 5px solid red ;
} :host ::ng-deep .p-inplace-content { padding : 20px ;
border : 5px solid green ;
border-radius: 10px ;
} |
app.component.ts:
import { Component } from "@angular/core" ;
@Component({ selector: "app-root" ,
templateUrl: "./app.component.html" ,
styleUrls: [ './app.component.css' ]
}) export class AppComponent { } |
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 { TableModule } from "primeng/table" ;
import { InplaceModule } from "primeng/inplace" ;
import { ButtonModule } from "primeng/button" ;
@NgModule({ imports: [
BrowserModule,
BrowserAnimationsModule,
InplaceModule,
FormsModule,
TableModule,
ButtonModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
}) export class AppModule { } |
Output:
Reference: http://primefaces.org/primeng/inplace