Tabs
Overview
Tabs allow applications to present a related set of content views within a small area, with only one content view displayed at a time. Each tab has a header with a brief text description of its content. Clicking on a tab header displays the content for that tab, hiding the content for all other tabs.
If you have buttons or other elements that apply only to the data within the selected tab, you can optionally include a toolbar within that tab. Tab toolbars display below the tab header, above the selected tabs content.
The tab component offers horizontal scrolling for tab headers when the width of all headers is greater than the available screen width. This generally works well on desktop systems, but the amount of scrolling that occurs at smaller screen widths (such as mobile) can make the tab component more difficult to work with in those environments. For this reason, it can be better to use the accordion functionality in the group box component at mobile size. This works similar to the tab component except the headers are displayed vertically, with the content displayed within whichever group box is expanded. Like the tab component, group boxes in accordion mode only display the content for the selected (expanded) group box.
Tabs only display the content of the currently selected tab, so when the user prints the page, the printout will only include the data in the currently selected tab. The same is true for a group box in accordion mode; only the content for the currently expanded group box will print. If users need a printout to include the data within all tabs and group boxes, you should provide a print-friendly version of this data.
Development
Web component development
Component reference
rui-tabset
Displays a horizontal list of options, with detail displayed for exactly one of those options
Name | Type | Default | Description |
---|---|---|---|
selectedTabId | string | '' | Contains the id of the currently selected tab |
slot | string | '' | Set to tab-header-extra to add additional markup next to the other tab labels. |
isFullHeight | bool | false | Set to true for fixed layout views where the tabset needs to fit its parent’s height. Leave at its default value of false otherwise. |
rui-selected-tab-change | event | Fires when the selected tab changes. The selected tab ID is passed as the event detail. | |
showTabByPosition(tabPosition) | method | Show the tab that’s in the specified 0-based position. The tabPosition parameter is a number between 0 and one less than the number of tabs in the tabset. | |
showTabByLabel(tabLabel) | method | Show the first tab that has the specified label. | |
showTabById(tabId) | method | Show the first tab that has the specified id. |
rui-tab
An individual tab in a tabset
Name | Type | Default | Description |
---|---|---|---|
labelText | string | '' | Text displayed in the tab header |
labelTooltip | string | '' | Title displayed when hovered over the tab header |
id | string | '' | Optional ID given to tab detail. If no ID is provided, one will be generated. |
badge | string | '' | Optional text highlighted in the tab header. Can be used to indicate a quick count of data items in the tab or some other text to highlight for the tab. |
isDisabled | boolean | false | Specifies whether the tab is disabled. |
slot | string | '' | Set to tab-label-extra to add additional markup directly following the tab label text. |
Implementation
Begin by importing the rui-tabs
module into your application.
Add a rui-tabset
element for each tab component. Nest a rui-tab
element within the rui-tabset
for each tab header, using the labelText
property to specify the tab header text.
Provide additional information or functionality using the available label and header slots.
Angular component development
Component reference
jha-tabset
Displays a horizontal list of options, with detail displayed for exactly one of those options
Name | Type | Default | Description |
---|---|---|---|
jhaIsFullHeight | bool | false | Set to true for fixed layout views where the tabset needs to fit its parent’s height. Leave at its default value of false otherwise. |
jhaSelectedTabChange | event | Fires when the selected tab changes. The selected tab ID is passed as the event detail. | |
showTabByPosition(tabPosition) | method | Show the tab that’s in the specified 0-based position. The tabPosition parameter is a number between 0 and one less than the number of tabs in the tabset. | |
showTabByLabel(tabLabel) | method | Show the first tab that has the specified label. | |
showTabById(tabId) | method | Show the first tab that has the specified id. |
jha-tab
An individual tab in a tabset
Name | Type | Default | Description |
---|---|---|---|
jhaLabelText | string | '' | Text displayed in the tab header |
jhaLabelTooltip | string | '' | Title displayed when hovered over the tab header |
jhaId | string | '' | Optional ID given to tab detail. If no jhaId is provided, one will be generated. |
jhaBadge | string | '' | Optional text highlighted in the tab header. Can be used to indicate a quick count of data items in the tab or some other text to highlight for the tab. |
jhaIsDisabled | boolean | false | Specifies whether the tab is disabled. |
slot | string | '' | Set to tab-label-extra to add additional markup directly following the tab label text. |
Implementation
Begin by importing the JhaLayoutModule
module into your application.
Add a jha-tabset
element for each tab component. Nest a jha-tab
element within the jha-tabset
for each tab header, using the jhaLabelText
property to specify the tab header text.
Provide additional information or functionality using the available label and header slots.
Component playground
Design
Figma design
Dev Component | Design Component Name |
---|---|
Tab bar | RUI / Layout / Tabs / Tab Bar |
Tab | RUI / Layout / Tabs / Tab Available values for the State property:
|
Add the base tab bar and resize its width to match its container’s width.
Add one active tab directly above the tab bar; change its title to an appropriate value.
Then add one or more inactive tabs directly above the tab bar; change the title in each to an appropriate value.
You can change the width of the active and inactive tabs to fit their title if needed.
Display sample content for the active tab.
Adobe XD design
- Sample App – Tabs
- Sample App - Content Layout
Dev Component | Design Component Name |
---|---|
Tab bar | JHA / Layout / Tabs / Tab Bar |
Tab - active | JHA / Layout / Tabs / Tab / Active |
Tab - inactive | JHA / Layout / Tabs / Tab / Inactive |
Add the base tab bar and resize its width to match its container’s width.
Add one active tab directly above the tab bar; change its title to an appropriate value.
Then add one or more inactive tabs directly above the tab bar; change the title in each to an appropriate value.
You can change the width of the active and inactive tabs to fit their title if needed.
Display sample content for the active tab.