Open In App

Angular PrimeNG Splitter Styling

Last Updated : 04 Jan, 2023
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 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:

  • p-splitter: It is the container element.
  • p-splitter: It is the container element during resizing.
  • p-splitter-horizontal: It is the container element with a horizontal layout.
  • p-splitter-vertical: It is the container element with a vertical layout.
  • p-splitter-panel: It is the splitter panel element.
  • p-splitter-gutter: It is the gutter element to use when resizing the panels.
  • p-splitter-gutter-handle: It is the handle element of the gutter.

 

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.

  • app.component.html

HTML




<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>


  • 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:

 

Example 2: In this example, we will learn about p-splitter-horizontal and p-splitter-vertical.

  • app.component.html

HTML




<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>


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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads