Angular PrimeNG Splitter Layout
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 see how to use the Splitter Layout in Angular PrimeNG.
The Splitter Component allows a user to split two-element using a splitter & utilized it separately and resize panels. The Layout property facilitates configuring the default orientation, which can be either “horizontal” or “vertical.” The default orientation is “horizontal”.
Syntax:
<p-splitter [style]="{'height': '...'}" layout="..."> <ng-template pTemplate> ... </ng-template> </p-splitter>
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: Write the below command to run the application:
ng serve --open
Example 1: This is the basic example that illustrates how to use the Angular PrimeNG Splitter Layout using the vertical layout.
HTML
< div style = "text-align: center" > < h2 style = "color:green" >w3wiki</ h2 > < h5 >Angular PrimeNG Splitter Layout</ h5 > </ div > < p-splitter layout = "vertical" > < ng-template pTemplate> < div class = "p-col p-ai-center p-jc-center" > 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. </ div > </ ng-template > < ng-template pTemplate> < div class = "p-col p-ai-center p-jc-center" > 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. </ div > </ ng-template > </ p-splitter > |
- app.component.ts:
Javascript
import { Component } from '@angular/core' ; @Component({ selector: 'my-app' , 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 { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { SplitterModule } from "primeng/splitter" ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, SplitterModule ], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} |
Output:
Example 2: Below is another example that illustrates the use of Angular PrimeNG Splitter Layout using the horizontal layout.
- app.component.html:
HTML
< div style = "text-align: center" > < h2 style = "color:green" > w3wiki </ h2 > < h5 >Angular PrimeNG Splitter Layout</ h5 > </ div > < p-splitter layout = "horizontal" > < ng-template pTemplate> < div class = "p-col p-ai-center p-jc-center" > 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. </ div > </ ng-template > < ng-template pTemplate> < div class = "p-col p-ai-center p-jc-center" > 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. </ div > </ ng-template > </ p-splitter > |
- 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 { SplitterModule } from "primeng/splitter" ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, SplitterModule], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} |
Output:
Reference: https://primefaces.org/primeng/splitter
Contact Us