Angular PrimeNG TabView 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 TabView Styling.Â
The TabView Component is used to display content in the form of tabs. In Styling, this component helps to make the interactive Form TabView by implementing the different stylings provided by Angular PrimeNG.
Angular PrimeNG TabView Styling: These styling components are described below
- p-tabview: It is the container element
- p-tabview-nav: It is the container of headers.
- p-tabview-selected: It is the selected tab header.
- p-tabview-panels: It is the container panels.
- p-tabview-panel: It is the content of a tab.
Syntax:
<p-tabView>
<p-tabPanel header="...">
......
</p-tabPanel>
</p-tabView>
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:
Â
- Step to run the application: Run the below command to see the output
ng serve --save
Example 1: In this example, we will see the basic usage of the p-tabview,p-tabview-nav, and p-tabview-selected classes for TabView Styling in Angular PrimeNG.
HTML
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >
Angular PrimeNG TabView Styling
</ h2 >
< p-tabView >
< p-tabPanel header = "TabView Component"
[selected]="true">
</ p-tabPanel >
< p-tabPanel header = "TabView Component" >
</ p-tabPanel >
< p-tabPanel header = "TabView Component" >
</ p-tabPanel >
</ p-tabView >
|
Javascript
import { Component } from '@angular/core' ;
@Component({
selector: 'app-root' ,
templateUrl: './app.component.html'
})
export class AppComponent {}
|
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 { TabViewModule } from "primeng/tabview" ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
TabViewModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
|
Output:
Â
Example 2: In this example, we will learn about p-tabview-panels and p-tabview-panel classes for TabView Styling in Angular PrimeNG.
HTML
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >
Angular PrimeNG TabView Styling
</ h2 >
< p-tabView >
< p-tabPanel header = "TabView Component" >
< p >Content1</ p >
</ p-tabPanel >
< p-tabPanel header = "TabView Component" >
< p >Content2</ p >
</ p-tabPanel >
< p-tabPanel header = "TabView Component" >
< p >Content3</ p >
</ p-tabPanel >
</ p-tabView >
|
Javascript
import { Component } from '@angular/core' ;
@Component({
selector: 'app-root' ,
templateUrl: './app.component.html'
})
export class AppComponent {}
|
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 { TabViewModule } from "primeng/tabview" ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
TabViewModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
|
Output:
Â
Reference: http://primefaces.org/primeng/tabview
Last Updated :
02 Feb, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...