Developer Programs

Learn

Docs

Tabs

Components > Content Layout > Tabs
Use this component to...
Organize content into sub-sections, only one of which is visible at a time

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.

Tab component with 3 tabs
Savings account content Checking account content Loan content
The accordion group box is similar to a tab component, although it displays vertically instead of horizontally.
Content Content Content

Development

Web component development

Component reference

rui-tabset
rui-tabset
Module: rui-tabs - Package: @jkhy/responsive-ui-wc

Displays a horizontal list of options, with detail displayed for exactly one of those options

NameTypeDefaultDescription
selectedTabIdstring''Contains the id of the currently selected tab
slotstring''Set to tab-header-extra to add additional markup next to the other tab labels.
isFullHeightboolfalseSet 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-changeeventFires when the selected tab changes. The selected tab ID is passed as the event detail.
showTabByPosition(tabPosition)methodShow 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)methodShow the first tab that has the specified label.
showTabById(tabId)methodShow the first tab that has the specified id.
rui-tab
rui-tab
Module: rui-tabs - Package: @jkhy/responsive-ui-wc

An individual tab in a tabset

NameTypeDefaultDescription
labelTextstring''Text displayed in the tab header
labelTooltipstring''Title displayed when hovered over the tab header
idstring''Optional ID given to tab detail. If no ID is provided, one will be generated.
badgestring''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.
isDisabledbooleanfalseSpecifies whether the tab is disabled.
slotstring''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.

Import the module
// import into app.module
import '@jkhy/responsive-ui-wc/components/rui-tabs/rui-tabs-imports';

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.

Tabset with 4 tabs, the 4th of which is disabled
<rui-tabset>

    <rui-tab labelText="Savings Accounts" id="saving-acct">
        Tab 1 content
    </rui-tab>

    <rui-tab labelText="Checking Accounts" id="checking-acct">
        Tab 2 content
    </rui-tab>

    <rui-tab labelText="Loans" badge="NEW" id="loans">
        Tab 3 content
    </rui-tab>

    <rui-tab labelText="Disabled" isDisabled="true" id="disabled-acct">
        Disabled tab content
    </rui-tab>
    
</rui-tabset>

Provide additional information or functionality using the available label and header slots.

Tabset using label and header slots
<rui-tabset>

    <rui-tab labelText="Savings Accounts" id="saving-acct">
        <div slot="tab-label-extra">
            <rui-grid-button iconType="edit" (rui-click)="editAcct()"></rui-grid-button>
        </div>
        Tab 1 content
    </rui-tab>

    <rui-tab labelText="Checking Accounts" id="checking-acct">
        Tab 2 content
    </rui-tab>

    <rui-tab labelText="Loans" badge="NEW" id="loans">
        Tab 3 content
    </rui-tab>

    <rui-tab labelText="Disabled" isDisabled="true" id="disabled-acct">
        Disabled tab content
    </rui-tab>

    <div slot="tab-header-extra">
        <rui-button text="Add New" iconType="add-new" (rui-click)="addNewTab()"></rui-button>
    </div>
    
</rui-tabset>

Angular component development

Component reference

jha-tabset
jha-tabset
Module: JhaLayoutModule - Package: @jkhy/responsive-ui-angular

Displays a horizontal list of options, with detail displayed for exactly one of those options

NameTypeDefaultDescription
jhaIsFullHeightboolfalseSet to true for fixed layout views where the tabset needs to fit its parent’s height. Leave at its default value of false otherwise.
jhaSelectedTabChangeeventFires when the selected tab changes. The selected tab ID is passed as the event detail.
showTabByPosition(tabPosition)methodShow 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)methodShow the first tab that has the specified label.
showTabById(tabId)methodShow the first tab that has the specified id.
jha-tab
jha-tab
Module: JhaLayoutModule - Package: @jkhy/responsive-ui-angular

An individual tab in a tabset

NameTypeDefaultDescription
jhaLabelTextstring''Text displayed in the tab header
jhaLabelTooltipstring''Title displayed when hovered over the tab header
jhaIdstring''Optional ID given to tab detail. If no jhaId is provided, one will be generated.
jhaBadgestring''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.
jhaIsDisabledbooleanfalseSpecifies whether the tab is disabled.
slotstring''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.

Import the module
// import into app.module
import { JhaLayoutModule } from '@jkhy/responsive-ui-angular/jha-layout';

@NgModule({
    imports: [
        ...
        JhaLayoutModule,
        ...
    ]
})

export class AppModule(){}

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.

Tabset with 4 tabs, the 4th of which is disabled
<jha-tabset>

    <jha-tab jhaLabelText="Savings Accounts" jhaId="savings-acct">
        Tab 1 content
    </jha-tab>

    <jha-tab jhaLabelText="Checking Accounts" jhaId="checking-acct">
        Tab 2 content
    </jha-tab>

    <jha-tab jhaLabelText="Loans" jhaBadge="NEW" jhaId="loans">
        Tab 3 content
    </jha-tab>

    <jha-tab jhaLabelText="Disabled" jhaIsDisabled="true" jhaId="disabled-acct">
        Disabled tab content
    </jha-tab>
    
</jha-tabset>

Provide additional information or functionality using the available label and header slots.

Tabset using label and header slots
<jha-tabset>

    <jha-tab jhaLabelText="Savings Accounts" jhaId="savings-acct">
        <div slot="tab-label-extra">
            <jha-grid-button jhaIconType="edit"></jha-grid-button>
        </div>
        Tab 1 content
    </jha-tab>

    <jha-tab jhaLabelText="Checking Accounts" jhaId="checking-acct">
        Tab 2 content
    </jha-tab>

    <jha-tab jhaLabelText="Loans" jhaBadge="NEW" jhaId="loans">
        Tab 3 content
    </jha-tab>

    <jha-tab jhaLabelText="Disabled" jhaIsDisabled="true" jhaId="disabled-acct">
        Disabled tab content
    </jha-tab>

    <div slot="tab-header-extra">
        <jha-button jhaText="Add New" jhaIconType="AddNew" (jhaClick)="addNewTab()"></jha-button>
    </div>
    
</jha-tabset>

Component playground


Design

Figma design

Figma design info
You can find this component in the Components - Content Layout page in the Figma UI Kit.
Dev ComponentDesign Component Name
Tab barRUI / Layout / Tabs / Tab Bar
Tab

RUI / Layout / Tabs / Tab

Available values for the State property:

  • Active
  • Inactive
  • Disabled

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

Adobe XD design info
You can find this component in these artboards in the Adobe XD design samples:
  • Sample App – Tabs
  • Sample App - Content Layout
Dev ComponentDesign Component Name
Tab barJHA / Layout / Tabs / Tab Bar
Tab - activeJHA / Layout / Tabs / Tab / Active
Tab - inactiveJHA / 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.


Support options
Have questions on this topic?
Join the Responsive UI team in Microsoft Teams to connect with the community.
See something in this page that needs to change?
Send us feedback on this page.
Last updated Tue Sep 24 2024