Open In App

Angular PrimeNG Splitter Styling

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 the Angular PrimeNG Splitter Styling.

The Splitter Component allows a user to split two-element using a splitter & utilized it separately and resize panels.



Angular PrimeNG Splitter Styling:

 



Syntax:

<p-splitter layout="Splitter Styling">
        Content
</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:

 

Example 1: This example describes the Angular PrimeNG Splitter Styling by implementing the p-splitter.




<div>
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>Angular PrimeNG Splitter Styling</h2>
</div>
  
<p-splitter [panelSizes]="[60, 40]" 
            [minSizes]="[20, 40]">
    <ng-template pTemplate>
        <div class="p-col p-ai-center p-jc-center">
            <img alt="gfg" src=
        </div>
    </ng-template>
  
    <ng-template pTemplate>
        <div class="p-col p-ai-center p-jc-center">
            <img alt="gfg" src=
        </div>
    </ng-template>
</p-splitter>




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




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: In this example, we will learn about p-splitter-horizontal and p-splitter-vertical.




<div>
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>Angular PrimeNG Splitter Styling</h2>
    <h4 style="color:red">
        Horizontal Splitter
    </h4>
  
    <p-splitter layout="horizontal">
        <ng-template pTemplate>
            <div>
                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
            </div>
        </ng-template>
  
        <ng-template pTemplate>
            <div>
                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
  
            </div>
        </ng-template>
    </p-splitter>
    <h4 style="color:red">
        Vertical Splitter
    </h4>
    <p-splitter [style]="{ height: '200px' }" 
                styleClass="p-mb-5" 
                layout="vertical">
        <ng-template pTemplate>
            <div class="p-col p-d-flex p-ai-center 
       p-jc-center">
                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.
            </div>
        </ng-template>
  
        <ng-template pTemplate>
            <div class="p-col p-d-flex p-ai-center 
       p-jc-center">
                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.
            </div>
        </ng-template>
    </p-splitter>
</div>




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




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: http://primefaces.org/primeng/splitter


Article Tags :