Encountered a problem today and found a solution by analyzing the hierarchy of classes generated by Vuetify in the inspector tool. By tweaking the CSS for specific classes, I was able to resolve the issue. The suggestion from this SO answer guided me to change the height of .v-tabs__content
, which led me to determine that the class structure has evolved.
<div>
<!-- Top level container of the tabbed interface -->
<nav>
<!-- Toolbar and tab header generated here -->
</nav>
<div class="v-window">
<div class="v-window__container">
<div class="v-window-item">
<div class="v-card">
<div class="v-card__text">Text.</div>
</div>
</div>
</div>
</div>
</div>
To adjust the tab content container's size appropriately, it became essential to modify the heights of v-window
, v-window__container
, and
v-window-item</code. Additionally, the internal content's height (e.g., the <code>v-card
) needed adjustment.
In my implementation, setting display:flex
for the container wrapper and utilizing flex
specifically for .v-window
ensured proper alignment below the toolbar while achieving the desired stretched height for the tab content.
View my solution on CodePen: https://codepen.io/anon/pen/wNEOdy, tailored to the provided example.
HTML:
<div id="app">
<v-app id="inspire">
<div class="tab-wrapper">
<v-toolbar
color="cyan"
dark
tabs
>
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-toolbar-title>Page title</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>search</v-icon>
</v-btn>
<v-btn icon>
<v-icon>more_vert</v-icon>
</v-btn>
<v-tabs
slot="extension"
v-model="model"
centered
color="cyan"
slider-color="yellow"
>
<v-tab
v-for="i in 3"
:key="i"
:href="`#tab-${i}`"
>
Item {{ i }}
</v-tab>
</v-tabs>
</v-toolbar>
<v-tabs-items v-model="model">
<v-tab-item
v-for="i in 3"
:key="i"
:value="`tab-${i}`"
>
<v-card flat>
<v-card-text v-text="text"></v-card-text>
</v-card>
</v-tab-item>
</v-tabs-items>
</div>
</v-app>
</div>
CSS:
.tab-wrapper {
height:100%; /* Set to desired height of entire tabbed section, or use flex, or ... */
display:flex;
flex-direction: column;
}
.tab-wrapper .v-window{
flex: 1;
}
.tab-wrapper .v-window__container,
.tab-wrapper .v-window-item {
height: 100%;
}
/* customise the dimensions of the card content here */
.tab-wrapper .v-card {
height: 100%;
}
JS:
new Vue({
el: '#app',
data () {
return {
model: 'tab-2',
text: '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.'
}
}
})