Open In App

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

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:

 

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.




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




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




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




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 { TabViewModule } from "primeng/tabview";
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        TabViewModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule {}

Output:

 

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


Article Tags :