Angular PrimeNG SplitButton Styling
Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. In this article, we will see Angular PrimeNG SplitButton Styling.
The SplitButton component is used to make a button a dropdown. This component helps to make the interactive SplitButton by implementing the different stylings provided by Angular PrimeNG.
Angular PrimeNG SplitButton Styling:
- p-splitbutton: It is the Container element.
- p-splitbutton-menubutton: It is the Dropdown button.
- p-menu: It is the Overlay menu.
Syntax:
<p-splitButton label="..." [model]="..."> </p-splitButton>
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 --save
Example 1: Below is the example code that illustrates the use of the Angular PrimeNG SplitButton Styling. In this example, we will learn how to style the p-splitbutton using styleClass in an HTML file..
- app.component.html:
HTML
< div style = "width: 80%;" > < h1 style = "color: green;" >GeeksforGeeks</ h1 > < h2 >Angular PrimeNG SplitButton Styling</ h2 > < p-splitButton styleClass = "geek" label = "GeeksforGeeks" [model]="gfg"> </ p-splitButton > </ div > |
- app.component.ts:
Javascript
import { Component, OnInit, ViewEncapsulation } from "@angular/core" ; import { MenuItem } from "primeng/api" ; import { MessageService } from "primeng/api" ; @Component({ selector: "app-root" , providers: [MessageService], templateUrl: "./app.component.html" , styleUrls: [ './app.component.css' ], }) export class AppComponent { gfg: MenuItem[] = []; constructor(private messageService: MessageService) {} ngOnInit() { this .gfg = [ { label: "Angular" }, { label: "PrimeNG" }, { label: "SplitButton" } ]; } } |
- app.module.ts:
Javascript
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { RouterModule } from "@angular/router" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { SplitButtonModule } from "primeng/splitbutton" ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, SplitButtonModule, RouterModule.forRoot([ { path: "" , component: AppComponent } ]) ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule {} |
- app.component.css:
CSS
:host ::ng-deep .geek { height : 100px ; width : 200px ; border : 2px solid rgb ( 131 , 63 , 63 ); } |
Output:

Example 2: Below is another example code that illustrates the use of the Angular PrimeNG SplitButton Styling. In this example, we will learn about styling the menu items by using styleClass in app.component.ts file.
- app.component.html:
HTML
< div style = "width: 80%;" > < h1 style = "color: green;" >GeeksforGeeks</ h1 > < h2 >Angular PrimeNG SplitButton Styling</ h2 > < p-splitButton label = "Primary SplitButton" icon = "pi pi-check" [model]="gfg"> </ p-splitButton > < p-splitButton label = "Secondary SplitButton" styleClass = "p-button-secondary" icon = "pi pi-hashtag" [model]="gfg"> </ p-splitButton > < p-splitButton label = "Success SplitButton" styleClass = "p-button-success" icon = "pi pi-circle" [model]="gfg"> </ p-splitButton > </ div > |
- app.component.ts:
Javascript
import { Component, OnInit, ViewEncapsulation } from "@angular/core" ; import { MenuItem } from "primeng/api" ; import { MessageService } from "primeng/api" ; @Component({ selector: "app-root" , providers: [MessageService], templateUrl: "./app.component.html" , styleUrls: [ './app.component.css' ], }) export class AppComponent { gfg: MenuItem[] = []; constructor(private messageService: MessageService) {} ngOnInit() { this .gfg = [ { label: "Angular" , styleClass: "geek" }, { label: "PrimeNG" , styleClass: "geek" }, { label: "SplitButton" , styleClass: "geek" } ]; } } |
- app.module.ts:
Javascript
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { RouterModule } from "@angular/router" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { SplitButtonModule } from "primeng/splitbutton" ; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, SplitButtonModule, RouterModule.forRoot([ { path: "" , component: AppComponent } ]) ], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule {} |
- app.component.css:
CSS
:host ::ng-deep .geek { background-color : lightgreen; color : green ; font-weight : bold ; border : 2px solid rgb ( 131 , 63 , 63 ); } |
Output

Reference: http://primefaces.org/primeng/splitbutton