Angular PrimeNG Divider Content
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. This article will show us how to use the Divider component in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.
The Divider Component is used to make a component that divides the content using a divider. Any inner material is shown inside the divider’s boundaries. Additionally, the align attribute controls where the material will appear. While “top,” “center,” and “bottom” are supported in vertical mode, “left,” “center,” and “right” are the alignment choices for horizontal layout.
Syntax:
<p>....</p> <p-divider align="..."> ... </p-divider> <p>...</p>
Angular PrimeNG Divider Content properties:
- align: It is used to set the alignment of the content. 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 code that illustrates the use of Angular PrimeNG Divider Content using left and center align.
- app.component.html:
HTML
< h1 style = "color: green" >w3wiki</ h1 > < h5 >Angular PrimeNG Divider Content</ h5 > < p > Angular PrimeNG is a framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. </ p > < p-divider align = "left" > < i class = "pi pi-user mr-1" ></ i > < b >w3wiki</ b > </ p-divider > < p > Angular PrimeNG is a framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. </ p > < p-divider align = "center" > < span class = "p-tag" >w3wiki</ span > </ p-divider > < p > Angular PrimeNG is a framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. </ p > |
- app.component.ts:
Javascript
import { Component } from "@angular/core" ; @Component({ selector: "app-root" , templateUrl: "./app.component.html" }) export class AppComponent {} |
- app.module.ts:
Javascript
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { DividerModule } from "primeng/divider" ; import { ButtonModule } from "primeng/button" ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, DividerModule, ButtonModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule {} |
Output:
Example 2: This is another example code that illustrates the use of Angular PrimeNG Divider Content using left and center align.
- app.component.html:
HTML
< h1 style = "color: green" >w3wiki</ h1 > < h5 >Angular PrimeNG Divider Content</ h5 > < p > Angular PrimeNG is a framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. </ p > < p-divider align = "right" > < p-button label = "Logout" icon = "pi pi-power-off" styleClass = "p-button-outlined" > </ p-button > </ p-divider > < p > Angular PrimeNG is a framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. </ p > < p-divider align = "center" > < span class = "p-tag" >w3wiki</ span > </ p-divider > < p > Angular PrimeNG is a framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites. </ p > |
- app.component.ts:
Javascript
import { Component } from "@angular/core" ; @Component({ selector: "app-root" , templateUrl: "./app.component.html" }) export class AppComponent {} |
- app.module.ts:
Javascript
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { DividerModule } from "primeng/divider" ; import { ButtonModule } from "primeng/button" ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, DividerModule, ButtonModule ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule {} |
Output:
Reference: https://primefaces.org/primeng/divider
Contact Us