Tabs organise and allow navigation between groups of content that are related and at the same level of hierarchy.
To select the active tab add the attribute
aria-selected="true" and that list item will have the correct styling.
To horizontally align the tab list with other content, the whole tab set can be contained within a
.row element to provide correct gutters.
There are two contexts in which this pattern can be used: as navigation, and as controls for panes of content.
The tabs pattern can be used as an alternative way to display a list of links.
Tab buttons can be used in two ways:
Secondary tabs: if the page already has a set of primary tabs used as navigation, as described above, these can be used as a sub-navigation of those primary tabs.
View switcher: in the case of a page in which the same piece of content is shown in more than one format, this component can be used as a switcher between the different views.
At smaller breakpoints, this pattern should be swapped out for one more suited to the available width, such as a select.
Use the class
p-tab-buttons to make your tabs appear as a group of buttons.
By adding the
is-dense modifier to the
p-tab-buttons element, the buttons will take on a more compact appearance.
The pattern also supports the use of icons within each button.
To import just the standard tab component into your project, copy the snippet below and include it in your main Sass file.
// import Vanilla and include base mixins // this only needs to happen once in a given project @import 'vanilla-framework/scss/vanilla'; @include vf-base; @include vf-p-tabs;
To import the tab button component into your project, copy the snippet below and include it in your main Sass file.
// import Vanilla and include base mixins // this only needs to happen once in a given project @import 'vanilla-framework/scss/vanilla'; @include vf-base; @include vf-p-tab-buttons;
For more information see Customising Vanilla in your projects, which includes overrides and importing instructions.
You can use tabs in React by installing our react-component library and importing