BlogPlaygroundOne

Tabs

The v-tabs component is used for hiding content behind a selectable item. This can also be used as a pseudo-navigation for a page, where the tabs are links and the tab-items are the content.

Usage

The v-tabs component is a styled extension of v-slide-group. It provides an easy to use interface for organizing content into separate sections.

One
<v-sheet elevation="2"> <v-tabs v-model="tab" color="primary"> <v-tab value="one">Item One</v-tab> <v-tab value="two">Item Two</v-tab> <v-tab value="three">Item Three</v-tab> </v-tabs> <v-divider></v-divider> <v-tabs-window v-model="tab"> <v-tabs-window-item value="one"> <v-sheet class="pa-5" color="purple">One</v-sheet> </v-tabs-window-item> <v-tabs-window-item value="two"> <v-sheet class="pa-5" color="orange">Two</v-sheet> </v-tabs-window-item> <v-tabs-window-item value="three"> <v-sheet class="pa-5" color="brown">Three</v-sheet> </v-tabs-window-item> </v-tabs-window> </v-sheet>
<script setup> import { ref } from 'vue' const tab = ref('one') </script>

API

ComponentDescription
v-tabsPrimary Component
v-tabSub-component used for modifying the v-tabs state
Toggle Inline API

Examples

Props

Align tabs

The align-tabs prop will align tabs to the start, center, or end of its container.

Align tabs with title

Make v-tabs line up with the v-toolbar-title component by setting the align-tabs prop to title (v-app-bar-nav-icon or v-btn must be used in v-toolbar).

Your Dashboard
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Center active

The center-active prop will make the active tab always centered.

Custom icons

prev-icon and next-icon can be used for applying custom pagination icons.

Fixed tabs

The fixed-tabs prop forces v-tab items to take up all available space up to 300px width, and centers them.

Grow

The grow prop will make the tab items take up all available space with no limit.

BASiL

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Stacked

Using stacked increases the v-tabs height to 72px to allow for both icons and text to be displayed.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Slider Transition

With slider-transition you can change default animation of the slider so it better fits with the app design.

slider-transition: fade, duration 900ms
slider-transition: grow

Pagination

If the tab items overflow their container, pagination controls will appear on desktop. For mobile devices, arrows will only display with the show-arrows prop.

Vertical tabs

The direction prop allows for v-tab components to stack vertically.

User Profile

Sed aliquam ultrices mauris. Donec posuere vulputate arcu. Morbi ac felis. Etiam feugiat lorem non metus. Sed a libero.

Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Aliquam lobortis. Aliquam lobortis. Suspendisse non nisl sit amet velit hendrerit rutrum.

Phasellus dolor. Fusce neque. Fusce fermentum odio nec arcu. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Phasellus blandit leo ut odio.

Spaced

Vertical tabs can be customized with spaced prop to move the text away from the icon.

Misc

Content

It is common to put v-tabs inside the extension slot of v-toolbar.

Page title
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Mobile tabs

On mobile you can use v-tab items with just icons to conserve space.

Contacts
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Dynamic Tabs

Tabs can be dynamically added and removed. In this example when we add a new tab, we automatically change our model to match. As we add more tabs and overflow the container, the selected item will be automatically scrolled into view. Remove all v-tab items and the slider will disappear.

Overflow to menu

You can use a menu to hold additional tabs, swapping them out on the fly.

Page title

Web

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Slots

Tab and window items

Use the tab and item slots with the items prop to reduce the markup required to build tabs.

Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ratione debitis quis est labore voluptatibus! Eaque cupiditate minima, at placeat totam, magni doloremque veniam neque porro libero rerum unde voluptatem!

Ready for more?

Continue your learning with related content selected by the Team or move between pages by using the navigation links below.