import {TabView} from 'primeng/primeng'; import {TabPanel} from 'primeng/primeng';
Tabview element consists of one or more p-tabPanel elements. Header of the tab is defined using header attribute.
<p-tabView> <p-tabPanel header="Header 1"> Content 1 </p-tabPanel> <p-tabPanel header="Header 2"> Content 2 </p-tabPanel> <p-tabPanel header="Header 3"> Content 3 </p-tabPanel> </p-tabView>
ActiveIndex property supports two-way binding, changes to the model updates the selected tab and changing the tab with user interaction updates the value at model.
<p-tabView [(activeIndex)]="index"> <p-tabPanel header="Header 1"> Content 1 </p-tabPanel> <p-tabPanel header="Header 2"> Content 2 </p-tabPanel> <p-tabPanel header="Header 3"> Content 3 </p-tabPanel> </p-tabView>
export class ModelComponent { index: number: 0; }
When closable attribute is enabled, an icon is displayed to close the tab. onClose event is fired when a tab is closed.
<p-tabPanel header="Header Text" closable="closable"> Content 1 </p-tabPanel>
An animation can be used when switching between tabs, valid values are "blind","bounce","clip","drop", "explode","fade","fold","highlight","puff","pulsate","scale","shake","size","slide","transfer". Duration of the effect is customized with effectDuration attributes using number values as milliseconds or pre-defined values such as "slow","normal" and "fast".
<p-tabView effect="fade" effectDuration="fast">
TabView has four different orientations; "top", "bottom", "left" and "right". Top is the default one and this can be changed using orientation attribute.
<p-tabView orientation="left">
Name | Type | Default | Description |
---|---|---|---|
activeIndex | number | 0 | Index of the active tab. |
orientation | String | top | Orientation of tab headers. |
effect | String | null | Animation to use when switching tabs. |
effectDuration | any | null | Duration of the effect in milliseconds or pre-defined values like "slow","normal" and "fast". |
onChange | function | null | Callback to invoke on tab change. |
onClose | function | null | Callback to invoke on tab close. |
Name | Parameters | Description |
---|---|---|
onChange |
event.originalEvent: Click event event.index: Index of the selected tab |
Callback to invoke on tab change. |
onClose |
event.originalEvent: Click event event.index: Index of the closed tab |
Callback to invoke on tab close. |
<p-tabView (onChange)="handleChange($event)">
export class ModelComponent { handleChange(e) { var index = e.index; } }
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
ui-tabview | Container element |
ui-tabview-nav | Container of headers. |
ui-tabview-selected | Selected tab header. |
ui-tabview-panels | Container panels. |
ui-tabview-panel | Content of a tab. |
jQuery, jQuery UI WidgetFactory API, PrimeUI TabView.
<h3 class="first">Default</h3> <p-tabView> <p-tabPanel header="Godfather I"> The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war, but does not intend to become part of his father's business. T hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family. </p-tabPanel> <p-tabPanel header="Godfather II"> Francis Ford C oppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy, killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows. </p-tabPanel> <p-tabPanel header="Godfather III"> After a break of more than 15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family. Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate. </p-tabPanel> </p-tabView> <h3>Active Index - {{activeTabIndex}}</h3> <p-tabView [(activeIndex)]="activeTabIndex"> <p-tabPanel header="Godfather I"> The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war, but does not intend to become part of his father's business. T hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family. </p-tabPanel> <p-tabPanel header="Godfather II"> Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy, killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows. </p-tabPanel> <p-tabPanel header="Godfather III"> After a break of more than 15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family. Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate. </p-tabPanel> </p-tabView> <h3>Closable</h3> <p-tabView> <p-tabPanel header="Godfather I"> The story begi ns as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war, but does not intend to become part of his father's business. T hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family. </p-tabPanel> <p-tabPanel header="Godfather II" closable="closable"> Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy, killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows. </p-tabPanel> <p-tabPanel header="Godfather III" closable="closable"> After a break of more than 15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family. Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate. </p-tabPanel> </p-tabView> <h3>Effect</h3> <p-tabView effect="fade" effectDuration="fast"> <p-tabPanel header="Godfather I"> The story begi ns as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war, but does not intend to become part of his father's business. T hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family. </p-tabPanel> <p-tabPanel header="Godfather II"> Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy, killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows. </p-tabPanel> <p-tabPanel header="Godfather III"> After a break of more than 15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family. Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate. </p-tabPanel> </p-tabView> <h3>Orientation</h3> <p-tabView orientation="left"> <p-tabPanel header="Godfather I"> The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war, but does not intend to become part of his father's business. T hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family. </p-tabPanel> <p-tabPanel header="Godfather II"> Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy, killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows. </p-tabPanel> <p-tabPanel header="Godfather III"> After a break of more than 15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family. Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate. </p-tabPanel> </p-tabView>
export class TabViewDemoComponent { activeTabIndex: number = 1; }