A component to switch between different views within the same context.
The components can be imported via:
PlumaTabs renders a group of tab buttons, and accepts their respective contents.
The component follows the WAI ARIA APG Tabs pattern.
It includes keyboard navigation (left/right arrows, Home and End keys to move between tabs, and Space or Enter to select a tab),
as well as accessibility support (via the recommended aria attributes).
It is not meant to be used for tabbed navigation where each tab is a link
to a different page, or the same page with different query parameters -
because links follow different semantic rules.
For a tabbed navigation interface that consists of links, please see PlumaTabNav.
PlumaTabs accepts a tabs array of objects, defined by the TabsTabItem interface.
A value (a unique id for the tab) and text string content must be provided for each tab.
Additionally, the tabs' contents should be provided, wrapped in PlumaTabsPanel components,
to associate them with their respective tab buttons (linked via the value string ids).
Intelligent, vocal, territorial, striking black-and-white bird
An initially selected tab can be chosen by providing the activeTab prop:
Pink and grey parrot with playful behavior and distinctive crest
The active tab state can be fully controlled by providing both activeTab and onChange:
Intelligent, vocal, territorial, striking black-and-white bird
Note: When onChange is provided, the component will no longer keep track
of the active tab internally, and activeTab will need to be set from the callback
for the tab state to change.
By default, tabs are aligned to the left (the start of the flex container). In some cases, we may need to change the alignment - for example when rendering tabs in a modal where we would like to center them, but still preserve the full-width bottom border.
The TabsList components is built using the InlineStack component,
and accepts the same props. In this case, the alignInline prop can control horizontal alignment.
Additionally, TabsList accepts a tabsListAlignInline prop, which is propagated
into the TabsList.
Intelligent, vocal, territorial, striking black-and-white bird
An icon can be rendered in a tab by setting the icon key on the tab object.
Additionally, the icon's color can be set with iconColor (which should be one of
the supported Icon component colors).
Tab 1 content
A Badge can be rendered in a tab by providing a badge string
on the tab object. The string will be rendered inside the badge.
Campaigns content
A tab can be disabled by setting isDisabled on the tab object:
Intelligent, vocal, territorial, striking black-and-white bird
The entire tab group can be disabled by setting isDisabled on the Tabs component:
Intelligent, vocal, territorial, striking black-and-white bird
The tabs component accepts a variant prop that can be used to change the style of the tabs.
The default value is default, while panel is available as an alternative.
The panel variant is meant to be used when the tabs are rendered on top of a panel component.
Additionally, enable the withTabs prop on the Panel itself to apply a
negative top margin, to make sure the tabs are visually "connected" to the panel.
Intelligent, vocal, territorial, striking black-and-white bird
The "panel" variant tabs also support icons and badges:
Campaigns content
By default, the tabs are rendered at the top of the panel. The tabs can by rending the <TabsList> component
at a different location within the component tree.
Intelligent, vocal, territorial, striking black-and-white bird
Tabs can be customized by using the PlumaTabsList and PlumaTabsTab components.
When using these components, a tabs array should not be used,
and activeTab along with onChange will need to be provided to control the currently active tab.
Tab 1 content
The currently active tab.
If none is provided, the component will default to the first tab from the tabs prop.
Use this prop along with onChange if you want to have full control over the active tab state.
Default:false
Whether the tab list should render without a border.
Whether all tabs should be disabled.
Default:true
Disable keyboard navigation via arrows and space/enter, which is enabled
by default, and recommended by the Tabs pattern.
Use this flag when the tabs are links (<a> tags), as links come with
their own accessibility semantics already.
Called when the active tab changes.
Array of tab items to display.
The alignInline argument passed through to the TabsList component.
Controls alignment of the tabs in the inline axis.
Additional classes to apply to any of the tabs
(each array item corresponding to the tabs array).
What style of tab to render.
Text content to show in a badge inside the tab.
An icon to show in the tab.
A color to apply to the icon.
Whether this tab is currently active/selected.
Whether this tab is disabled.
The text content to show in the tab.
A unique value for the tab, used for identifying the currently active tab.
PlumaTabsList extends InlineStackArray of tab items to display.
Additional classes to apply to any of the tabs
(each array item corresponding to the tabs array).
Text content to show in a badge inside the tab.
An icon to show in the tab.
A color to apply to the icon.
Whether this tab is currently active/selected.
Whether this tab is disabled.
A unique value for the tab, used for identifying the currently active tab.
Which tab this panel corresponds to.