Vuetify is a popular UI framework for Vue apps.
In this article, we’ll look at how to work with the Vuetify framework.
Prominent App Bar with Scroll Shrink and Image, Fading on Scroll
We can add the fade-img-on-scroll prop to v-app-bar to make the background image of our app bar disappear on scroll.
For example, we can write:
<template>
<v-container>
<v-row class="text-center">
<v-col col="12">
<v-card class="overflow-hidden">
<v-app-bar
absolute
color="green"
dark
shrink-on-scroll
prominent
src="https://picsum.photos/1920/1080?random"
fade-img-on-scroll
scroll-target="#scrolling"
>
<template v-slot:img="{ props }">
<v-img
v-bind="props"
gradient="to top right, rgba(100,115,201,.7), rgba(25,32,72,.7)"
></v-img>
</template>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-heart</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
<template v-slot:extension>
<v-tabs align-with-title>
<v-tab>Tab 1</v-tab>
<v-tab>Tab 2</v-tab>
<v-tab>Tab 3</v-tab>
</v-tabs>
</template>
</v-app-bar>
<v-sheet id="scrolling" class="overflow-y-auto" max-height="600">
<v-container style="height: 1000px;"></v-container>
</v-sheet>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
drawer: false,
}),
};
</script>
We have a v-app-bar with the fade-img-on-scroll prop to make the image disappear when we scroll.
App Bar With Menu
We can add an app bar with a menu with the VMenu component.
For example, we can write:
<template>
<v-container>
<v-row class="text-center">
<v-col col="12">
<v-card class="overflow-hidden">
<v-app-bar
absolute
color="#6A76AB"
dark
shrink-on-scroll
prominent
src="https://picsum.photos/1920/1080?random"
fade-img-on-scroll
scroll-target="#scrolling"
>
<template v-slot:img="{ props }">
<v-img
v-bind="props"
gradient="to top right, rgba(100,115,201,.7), rgba(25,32,72,.7)"
></v-img>
</template>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Title</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-heart</v-icon>
</v-btn>
<v-menu bottom left>
<template v-slot:activator="{ on, attrs }">
<v-btn icon color="yellow" v-bind="attrs" v-on="on">
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</template>
<v-list>
<v-list-item v-for="i in 3" :key="i">
<v-list-item-title>item {{ i }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<template v-slot:extension>
<v-tabs align-with-title>
<v-tab>1</v-tab>
<v-tab>2</v-tab>
<v-tab>3</v-tab>
</v-tabs>
</template>
</v-app-bar>
<v-sheet id="scrolling" class="overflow-y-auto" max-height="600">
<v-container style="height: 1000px;"></v-container>
</v-sheet>
</v-card>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({}),
};
</script>
We have a v-app-bar with a v-menu with different items.
The items are in the v-list ‘s v-list-item components.
The menu text is in the v-list-item-title text.
Conclusion
We can change the app to fade the image on scroll and add a menu with Vuetify.