TabView is a container component to group content with tabs.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Tab 1 Content
import { TabView, TabPanel } from 'primereact/tabview';
<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/tabview/tabview.min.js"></script>
Tabview element consists of one or more TabPanel elements and can either be used as a Controlled or Uncontrolled component.
In controlled mode, activeIndex and onTabChange properties need to be defined to control the state.
const [activeIndex, setActiveIndex] = useState(0);
<TabView activeIndex={activeIndex} onTabChange={(e) => setActiveIndex(e.index)}>
<TabPanel header="Header I">
Content I
</TabPanel>
<TabPanel header="Header II">
Content II
</TabPanel>
<TabPanel header="Header III">
Content III
</TabPanel>
</TabView>
In uncontrolled mode, no additional properties are required. Initial active tab can be provided using the activeIndex property in uncontrolled mode however it is evaluated at initial rendering and ignored in further updates. If you programmatically need to update the active tab, prefer to use the component as controlled.
<TabView>
<TabPanel header="Header I">
Content I
</TabPanel>
<TabPanel header="Header II">
Content II
</TabPanel>
<TabPanel header="Header III">
Content III
</TabPanel>
</TabView>
The header element is fully customizable on TabPanel. To make special header, an object can be given to the headerTemplate property as below.
<TabView>
<TabPanel header="Header I" headerTemplate={template}>
Content I
</TabPanel>
</TabView>
template: (options) => {
// options.className: Style class of the default header element.
// options.titleClassName: Style class of the title element.
// options.onClick: Click event for the header element.
// options.leftIconElement: Default left icon element created by the component.
// options.titleElement: Default title element created by the component.
// options.rightIconElement: Default right icon element created by the component.
// options.element: Default element created by the component.
// options.props: component props.
// options.index: The index of tab.
// options.selected: Whether the panel is selected.
// options.ariaControls: The value of aria-controls property.
}
Name | Type | Default | Description |
---|---|---|---|
header | any | null | Orientation of tab headers. |
headerTemplate | any | null | Header template of the tab to customize more. |
leftIcon | string | null | Icons can be placed at left of a header. |
rightIcon | string | null | Icons can be placed at right of a header. |
disabled | boolean | false | Whether the tab is disabled. |
closable | boolean | false | Defines if tab can be removed. |
style | object | null | Inline style of the tab header and content. |
className | string | null | Style class of the tab header and content. |
headerStyle | object | null | Inline style of the tab header. |
headerClassName | string | null | Style class of the tab header. |
contentStyle | object | null | Inline style of the tab content. |
contentClassName | string | null | Style class of the tab content. |
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
activeIndex | number | 0 | Active index of the TabView. |
style | object | null | Inline style of the tabview. |
className | string | null | Style class of the tabview. |
renderActiveOnly | boolean | true | Whether to render the contents of the selected tab or all tabs. |
scrollable | boolean | false | When enabled displays buttons at each side of the tab headers to scroll the tab list. |
panelContainerStyle | object | null | Inline style of the panels container of the tabview. |
panelContainerClassName | string | null | Style class of the panels container of the tabview. |
Name | Parameters | Description |
---|---|---|
onBeforeTabChange | event.originalEvent: Browser event event.index: Index of the selected tab | Callback to invoke before an active tab is changed. Return false to prevent tab from changing. |
onBeforeTabClose | event.originalEvent: Browser event event.index: Index of the selected tab | Callback to invoke before an active tab is close. Return false to prevent tab from closing. |
onTabChange | event.originalEvent: Browser event event.index: Index of the selected tab | Callback to invoke when an active tab is changed. |
onTabClose | event.originalEvent: Browser event event.index: Index of the selected tab | Callback to invoke when an active tab is closed. |
Name | Parameters | Description |
---|---|---|
reset | - | Resets all states. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-tabview | Container element. |
p-tabview-nav | Container of headers. |
p-tabview-selected | Selected tab header. |
p-tabview-panels | Container panels. |
p-tabview-panel | Content of a tab. |
This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.
None.
Built-in component themes created by the PrimeReact Theme Designer.
Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.
Beautifully crafted premium create-react-app application templates by the PrimeTek design team.