Tabs
Tabs are used to organize and group content into sections that the user can navigate between.
new tab
<vaadin-tabs>
<vaadin-tab>Details</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
Use Tabs when you want to allow in-place navigation within a certain part of the UI, instead of showing everything at once or forcing the user to navigate between different views.
States
A Tab can be selected, unselected, or disabled.
new tab
<vaadin-tabs>
<vaadin-tab>Selected</vaadin-tab>
<vaadin-tab>Unselected</vaadin-tab>
<vaadin-tab disabled>Disabled</vaadin-tab>
</vaadin-tabs>
Disable a Tab to mark it as unavailable. Disabled Tabs cannot be focused and may be invisible to assistive technologies like screen readers.
Disabling can be preferable to hiding an element to prevent changes in layout when the element’s visibility changes, and to make users aware of its existence even when unavailable.
Orientation & Scrolling
Tabs support two different orientations: horizontal (default) and vertical. Base the choice of orientation on the use case and the available space.
Horizontal
Horizontal tabs may be easier for users to understand and associate with their contents. They are best suited for a small number of items, but provide scrolling on overflow.
new tab
<vaadin-tabs style="max-width: 100%; width: 400px;">
<vaadin-tab>Analytics</vaadin-tab>
<vaadin-tab>Customers</vaadin-tab>
<vaadin-tab>Dashboards</vaadin-tab>
<vaadin-tab>Documents</vaadin-tab>
<vaadin-tab>Orders</vaadin-tab>
</vaadin-tabs>
Vertical
Vertical tabs can be a better choice for a big number of items, as it’s easier for the user to scan a vertical list of options. They may be somewhat less easy to understand and associate with their contents, however. Vertical tabs also provide scrolling on overflow.
new tab
<vaadin-tabs orientation="vertical" style="height: 240px; width: 240px;">
<vaadin-tab>Analytics</vaadin-tab>
<vaadin-tab>Customers</vaadin-tab>
<vaadin-tab>Dashboards</vaadin-tab>
<vaadin-tab>Documents</vaadin-tab>
<vaadin-tab>Orders</vaadin-tab>
<vaadin-tab>Products</vaadin-tab>
<vaadin-tab>Tasks</vaadin-tab>
</vaadin-tabs>
Hide Scroll Buttons
Horizontal Tabs display scroll buttons to aid with scrolling when their contents overflow.
The buttons show that there are more tabs to either side.
Hide the buttons by applying the hide-scroll-buttons
theme variant.
new tab
<vaadin-tabs theme="hide-scroll-buttons">
<vaadin-tab>Analytics</vaadin-tab>
<vaadin-tab>Customers</vaadin-tab>
<vaadin-tab>Dashboards</vaadin-tab>
<vaadin-tab>Documents</vaadin-tab>
<vaadin-tab>Orders</vaadin-tab>
<vaadin-tab>Products</vaadin-tab>
<vaadin-tab>Tasks</vaadin-tab>
</vaadin-tabs>
Note | Hiding the scroll buttons is not recommended for UIs designed to be operated on non-touchscreen devices, as horizontal scrolling can be difficult without them. |
Icons and Other Tab Content
Tabs can contain more than just text.
Icons
Icons can be used to make tabs more prominent and easier to identify. They can be added next to, or above the labels.
Horizontal Tabs work best with icons above the labels.
new tab
<vaadin-tabs>
<vaadin-tab theme="icon-on-top">
<vaadin-icon icon="vaadin:user"></vaadin-icon>
<span>Profile</span>
</vaadin-tab>
<vaadin-tab theme="icon-on-top">
<vaadin-icon icon="vaadin:cog"></vaadin-icon>
<span>Settings</span>
</vaadin-tab>
<vaadin-tab theme="icon-on-top">
<vaadin-icon icon="vaadin:bell"></vaadin-icon>
<span>Notifications</span>
</vaadin-tab>
</vaadin-tabs>
Vertical Tabs work best with icons next to labels.
new tab
<vaadin-tabs orientation="vertical">
<vaadin-tab>
<vaadin-icon icon="vaadin:user"></vaadin-icon>
<span>Profile</span>
</vaadin-tab>
<vaadin-tab>
<vaadin-icon icon="vaadin:cog"></vaadin-icon>
<span>Settings</span>
</vaadin-tab>
<vaadin-tab>
<vaadin-icon icon="vaadin:bell"></vaadin-icon>
<span>Notifications</span>
</vaadin-tab>
</vaadin-tabs>
Other Elements
Tabs can contain virtually any UI elements, such as badges indicating the number of items per tab.
new tab
<!--
NOTE: You need import the 'lumo-badge' style sheets to use theme="badge"
-->
<vaadin-tabs>
<vaadin-tab>
<span>Open</span>
<span theme="badge small contrast">24</span>
</vaadin-tab>
<vaadin-tab>
<span>Completed</span>
<span theme="badge small contrast">439</span>
</vaadin-tab>
<vaadin-tab>
<span>Cancelled</span>
<span theme="badge small contrast">5</span>
</vaadin-tab>
</vaadin-tabs>
Theme Variants
Centered
Tabs are by default left-aligned. They can be centered using the centered theme variant.
new tab
<vaadin-tabs theme="centered">
<vaadin-tab>Details</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
Usage recommendations
Visual and/or stylistic preference
Typically used for top-level navigation
Use with caution; default left-aligned tabs are more discoverable.
Equal Width Tabs
Apply the equal-width-tabs
theme variant to make each Tab share the available space.
Please note that this disables the possibility for scrolling as the content never overflows.
new tab
<vaadin-tabs theme="equal-width-tabs">
<vaadin-tab>Details</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
Usage recommendations
For a small number of tabs in a horizontally narrow space, such as:
Tabbed sidebar
Mobile (portrait) layouts
Minimal
Reduces visual styles to a minimum.
new tab
<vaadin-tabs theme="minimal">
<vaadin-tab>Details</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
Usage recommendations
To reduce visual clutter
Use with caution, as this reduces the visual distinction for selected tabs to only color, which can be difficult to discern for many users.
Small
The small
theme variant can be used to make the Tabs smaller.
new tab
<vaadin-tabs theme="small">
<vaadin-tab>Details</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
Usage recommendations
When space is limited
Focus and Keyboard
Tab focus is rendered differently when focused by keyboard.
new tab
<vaadin-tabs>
<vaadin-tab focus-ring>Details</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
Once a tab is focused, arrow keys can be used to move the focus between tabs. Press Enter or Space to select the focused tab.
Common Cases
Switching Between Content
The most common use for Tabs is to switch between different sets of content within the same view.
new tab
<vaadin-tabs @selected-changed="${this.selectedChanged}">
<vaadin-tab>Dashboard</vaadin-tab>
<vaadin-tab>Payment</vaadin-tab>
<vaadin-tab>Shipping</vaadin-tab>
</vaadin-tabs>
<vaadin-vertical-layout theme="padding">
<p>${this.content}</p>
</vaadin-vertical-layout>
Navigation
Tabs are often used for an application’s top-level navigation. See App Layout for examples. Anchor elements should be used inside the tabs to provide the navigation mechanism.