lara-light-indigo

TabView

TabView is a container component to group content with tabs.

Default

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.

Programmatic

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.

Disabled

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.

Header Icons

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.

Custom Headers

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.

Closable

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.

Import via Module

import { TabView, TabPanel } from 'primereact/tabview';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/tabview/tabview.min.js"></script>
 
Getting Started

Tabview element consists of one or more TabPanel elements and can either be used as a Controlled or Uncontrolled component.

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

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

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.
}
 
Properties For TabPanel
NameTypeDefaultDescription
headeranynullOrientation of tab headers.
headerTemplateanynullHeader template of the tab to customize more.
leftIconstringnullIcons can be placed at left of a header.
rightIconstringnullIcons can be placed at right of a header.
disabledbooleanfalseWhether the tab is disabled.
closablebooleanfalseDefines if tab can be removed.
styleobjectnullInline style of the tab header and content.
classNamestringnullStyle class of the tab header and content.
headerStyleobjectnullInline style of the tab header.
headerClassNamestringnullStyle class of the tab header.
contentStyleobjectnullInline style of the tab content.
contentClassNamestringnullStyle class of the tab content.
Properties For TabView
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
activeIndexnumber0Active index of the TabView.
styleobjectnullInline style of the tabview.
classNamestringnullStyle class of the tabview.
renderActiveOnlybooleantrueWhether to render the contents of the selected tab or all tabs.
scrollablebooleanfalseWhen enabled displays buttons at each side of the tab headers to scroll the tab list.
panelContainerStyleobjectnullInline style of the panels container of the tabview.
panelContainerClassNamestringnullStyle class of the panels container of the tabview.
Events
NameParametersDescription
onBeforeTabChangeevent.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.
onBeforeTabCloseevent.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.
onTabChangeevent.originalEvent: Browser event
event.index: Index of the selected tab
Callback to invoke when an active tab is changed.
onTabCloseevent.originalEvent: Browser event
event.index: Index of the selected tab
Callback to invoke when an active tab is closed.
Methods
NameParametersDescription
reset-Resets all states.
Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-tabviewContainer element.
p-tabview-navContainer of headers.
p-tabview-selectedSelected tab header.
p-tabview-panelsContainer panels.
p-tabview-panelContent of a tab.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma