Tabs
Tabs organize content into multiple sections, allowing users to switch between views within the same context.
Personal information
Education history of Tim Jenssen
2020 - 2023 Da Vinci International SchoolPhoto by Xia Yang
<sl-tab-group style="background: var(--sl-color-tab-default-background); inline-size: 500px">
<sl-tab selected>Personal information</sl-tab>
<sl-tab>Education</sl-tab>
<sl-tab disabled>Projects</sl-tab>
<sl-tab-panel>
Personal information...
</sl-tab-panel>
<sl-tab-panel>
Education history of...
</sl-tab-panel>
<sl-tab-panel>
...
</sl-tab-panel>
</sl-tab-group>
When to use
Tabs are suitable for organizing content into distinct categories or sections within a single view.
Segmenting Content
Tabs are ideal for clustering content when they can be split into separate sections or categories. By grouping related information into different tabs, it reduces overload, and users can navigate through content more efficiently, thus helping to decrease cognitive load.
Enhanced Workflow
Tabs facilitate seamless user task completion by organizing content like forms, settings, and dashboards within the same interface, eliminating the need for users to navigate away from their workflow.
When not to use
While tabs can be a valuable clustering tool, they might not always be the best choice. Here are some scenarios where you need to find different alternatives.
Simultaneously Content
Avoid using tabs if users need to compare information in two groups, as constant switching between tabs increases cognitive load and interaction cost. Don't use it when users don't need to view content from multiple tabs simultaneously.
Hiding Information
Be cautious when hiding critical information behind tabs, leading users to overlook important details and ensuring that essential information is readily accessible without excessive tab navigation, enhancing user experience and usability. Additionally, nesting tabs within tabs can create usability issues and confuse users. Instead, consider alternative components like accordions.
Anatomy
Tabs are a combination of a tab list and a tab panel. The tab list contains the navigation tabs. When there is overflow, it shows the "more button" to open the tabs popover. The tab panel presents content for selected tabs.
Item | Name | Description | Optional |
---|---|---|---|
1 | Icon | The icon improves the visibility. | Yes |
2 | Title | The tab's label needs to be clear and direct to make it easier for the user to scan through the content. | Yes |
3 | Subtitle | A description text clarifies the content the user will find in the tab panel. | Yes |
4 | Badge | Give the user some quotes about whether there is new content or the need to review the panel content. | Yes |
5 | Indicator | Visual distinction of the tab to make it easy to see between an active and inactive tab. | no |
6 | Tab | Interactive button to display the tab panel related to the tab. | no |
7 | More Button | Button to show the tabs menu when there is a hidden tab. | no |
Tabs Popover
When overflow occurs, we provide a "more button" to display the hidden tabs. We are using the popover; you can check more details here.
States and Status
Tabs come with multiple states, each suited for different interactions, and two status. The states provided are default, hover, active, disabled and focus, but we need to differentiate between those two alternative status:
Unselected: This tab appearance is the inactive version and provides a visually clear design. Making it easy for the user to scan the content and make a quick choice.
Selected: This tab appearance is the inactive version and provides a visually clear distinction to make it easier for the user to see where they are in the interface.
Orientation
The orientation of tabs plays a significant role in determining the layout and functionality of the user.
Horizontal: In this orientation, tabs are arranged side by side, at the top of the content area. It provides much more space optimization. They offer easy access to the content and are commonly used in desktop applications or website interfaces.
Vertical: This version displays the tabs in a column stack, usually along the left or right side of the panel. Vertical tabs are beneficial when the content height exceeds its width, providing efficient navigation for lengthy lists or categories.
Figma Options
With these options, you can tweak the appearance of the tabs in Figma. They are available in the Design Panel so you can compose the tabs to exactly fit the user experience need for the use case you are working on.
Tab List
The tab list provides the options to set up the version of the component that you need.
Item | Options | Description |
---|---|---|
Subtitles | boolean | Toggle to display the subtitle in the tabs. |
Alignement | left filled | Define the behaviour of the tab related to the tab list. |
More Button | boolean | Toggle to display the overflow button in the tabs list. |
Tabs
This are the tab buttons to switch between content.
Item | Options | Description |
---|---|---|
State | default hover active aisabled | Define the behaviour of the tab related to the tab list. |
Badge | boolean | Toggle to display the badge in the tabs. |
Icon | boolean | Toggle to display the icon in the tabs. |
Icon Only | boolean | Toggle to switch only icon tabs. |
Title | value | Text input to insert the title. |
Subtitle | value | Text input to insert the subtitle. |
Behavior
Understanding the behavior of tabs is crucial for creating intuitive and user-friendly content access. Tabs exhibit various characteristics and functionalities that impact how users interact with them.
No Label Wrap
When the labels may exceed the available space, especially in lengthy titles. We don't wrap the labels, preventing truncation to ensure users can still identify and access tabs without sacrificing usability. To solve the hide tabs, we provide an overflow tabs button.
Focusable Area
Tabs should provide a focusable area to accommodate keyboard navigation. The focusable area allows users to navigate between tabs, enhancing usability and accessibility for all users.
Overflow Tabs
In cases where the number of tabs exceeds the available space, overflow buttons offer a solution for managing tab visibility. The overflow tabs menu provides a solution for accessing hidden tabs. The tabs list is also scrollable, allowing users to move horizontally to view additional tabs.
<sl-tab-group style="background: var(--sl-color-tab-default-background);">
<sl-tab >Tab 1</sl-tab>
<sl-tab selected>Tab 2</sl-tab>
<sl-tab disabled>Tab 3</sl-tab>
<sl-tab>Tab 4</sl-tab>
<sl-tab>Tab 5</sl-tab>
<sl-tab-panel>Panel 1</sl-tab-panel>
<sl-tab-panel>Panel 2</sl-tab-panel>
<sl-tab-panel>Panel 3</sl-tab-panel>
<sl-tab-panel>Panel 4</sl-tab-panel>
<sl-tab-panel>Panel 5</sl-tab-panel>
</sl-tab-group>
Tab group API
Component has a range of properties to define the experience in different use cases.
Properties
Name | Attribute | Type | Default | Description |
---|---|---|---|---|
alignTabs | align-tabs | 'start' | 'center' | 'end' | 'stretch' | undefined | The alignment of tabs within the wrapper. | |
vertical | vertical | boolean | undefined | Renders the tabs vertically instead of the default horizontal |
Events
Name | Event type | Description |
---|---|---|
sl-tab-change | SlTabChangeEvent | Emits when the tab has been selected/changed. |
Slots
Name | Description |
---|---|
default | Tab panels or other tab content here. |
tabs | The tabs to display. |
CSS Properties
Name | Description |
---|---|
--sl-tab-group-menu-min-inline-size | The minimum inline size of the menu. |
--sl-tab-group-menu-max-inline-size | The maximum inline size of the menu. |
CSS Parts
Name | Description |
---|---|
container | The container for the tabs. |
wrapper | Wraps the scroll container and menu button. |
scroller | The scroll container of the tabs. |
tablist | The tablist element which also contains the active tab indicator |
panels | The container for the tab panels. |
Tab panel API
Component has a range of properties to define the experience in different use cases.
Slots
Name | Description |
---|---|
default | A place for the tab panel content. |
Tab API
Component has a range of properties to define the experience in different use cases.
Properties
Name | Attribute | Type | Default | Description |
---|---|---|---|---|
disabled | disabled | boolean | undefined | Whether the tab item is disabled. | |
href | href | string | undefined | When set, it will render the tab contents in a link tag. Use this when you want to render the tab contents using a router and to make the tab navigatable by URL. | |
selected | selected | boolean | undefined | Whether the tab item is selected. |
Slots
Name | Description |
---|---|
default | A place for the tab group content. |
icon | Icon shown on the left side of the component. |
badge | A place for badge component. |
subtitle | Subtitle of the tab, containing additional information. |
Content
Creating an inclusive application requires more than just writing great code. It also involves writing clear and concise copy. Keep the users while writing the tab's titles and subtitles.
Short Tab Labels
Use plain language and keep labels short, usually 1-2 words. Longer labels may indicate that choices are too complex for a tab control. Simplify options to make them user-friendly.
No All Uppercase
Avoid using all caps for tab labels. It's harder to read. Use consistent capitalization style, either sentence-case or title-style.
Keyboard interactions
Keyboard interactions within a tabs group allow users to navigate options using arrow keys or the Tab key, facilitating efficient selection and ensuring accessibility for those who rely on keyboard navigation. Typically, users can navigate to the tabs using the "Tab" key, once they're in the first tab they can focus the different options with Arrow keys. Then they can select a new tab with the "Spacebar" or "Enter" key. Keyboard interaction ensures that individuals who rely on keyboard navigation or assistive technologies can easily control tabs within a user interface.
Key | Description |
---|---|
Tab | Shifts focus to the first tab control in a tab list. Or when a tabs is focuse the focus will go the the active tab in the page when the tab key is pressed |
Space/Enter | Activates the currently focused tab or open the overflow menu |
Arrow Keys | Once you are "in" a tabs list you can navigate to the next tab by using the right or down arrow key. You can navigate back to the previous tab with left or up. The focus indicator loops, so when you are at the last tab and press "down" it will focus the first tab. |
WAI-ARIA
WAI-ARIA Roles, States, and Properties for tabs provide essential information to assistive technologies and screen readers. They convey the tabs's role, state (checked, unchecked, valid and invalid), and additional properties to ensure accessibility and a better user experience for individuals using assistive technology.
Tab Group
Attribute | Value | Description | User supplied |
---|---|---|---|
role | 'tablist' | Makes it clear that element is a container for a set of tabs. | no |
aria-labelledby | string | The purpose of tabs - can be set to the id of labelling element. | yes |
Tab
Attribute | Value | Description | User supplied |
---|---|---|---|
role | 'tab' | Declare element as a tab control. | no |
aria-selected | string | Indicates the tab control is activated or not and its associated panel is displayed or not as well. Set to true when a user activates a tab. | no |
aria-controls | string | It contains id of the tab panel element associated with the tab. | no |
Tab panel
Attribute | Value | Description | User supplied |
---|---|---|---|
role | 'tabpanel' | Declare the element as a container for tab panel content. | no |
aria-labelledby | string | Used to connect tab control with tab panel. Refers to the tab element that controls the panel; contains id of the tab control. | no |