Vuetify — Bottom Sheet. A container to display content.
By: John Au-Yeung
Tags: JavaScript, Web Development, Software Development, Technology, Programming

Photo by bantersnaps on Unsplash

Vuetify is a popular UI framework for Vue apps.

In this article, we’ll look at how to work with the Vuetify framework.

Bottom Nav Bar Scroll Threshold

We can set the scroll-threshold of the v-bottom-navigation to show the navbar depending on the threshold.

For example, we can write:

<template>

<v-container>

<v-row class="text-center">

<v-col col="12">

<v-card class="overflow-hidden mx-auto" height="200" max-width="500">

<v-bottom-navigation

scroll-target="#scroll-area"

hide-on-scroll

absolute

horizontal

scroll-threshold="500"

>

<v-btn text color="deep-purple accent-4">

<span>History</span>

<v-icon>mdi-history</v-icon>

</v-btn> <v-btn text color="deep-purple accent-4">

<span>Favorites</span>

<v-icon>mdi-heart</v-icon>

</v-btn> <v-btn text color="deep-purple accent-4">

<span>Map</span>

<v-icon>mdi-map-marker</v-icon>

</v-btn>

</v-bottom-navigation> <v-sheet id="scroll-area" class="overflow-y-auto" max-height="600">

<v-container style="height: 1500px;"></v-container>

</v-sheet>

</v-card>

</v-col>

</v-row>

</v-container>

</template> <script>

export default {

name: "HelloWorld",

data: () => ({

activeBtn: undefined,

showNav: false,

}),

};

</script>

We add the scroll-threshold prop to set the number of pixels to scroll down until the navbar is shown.

Bottom Sheets

The bottom sheet is another container for content.

It shows at the bottom of the page.

We can add one with the v-bottom-sheet component:

<template>

<v-container>

<v-row class="text-center">

<v-col col="12">

<v-card class="overflow-hidden mx-auto" height="200" max-width="500">

<v-bottom-sheet v-model="sheet" persistent>

<template v-slot:activator="{ on, attrs }">

<v-btn color="green" dark v-bind="attrs" v-on="on">Open Persistent</v-btn>

</template>

<v-sheet class="text-center" height="200px">

<v-btn class="mt-6" text color="error" @click="sheet = !sheet">close</v-btn>

<div class="py-3">Lorem ipsum</div>

</v-sheet>

</v-bottom-sheet>

</v-card>

</v-col>

</v-row>

</v-container>

</template> <script>

export default {

name: "HelloWorld",

data: () => ({

sheet: false,

}),

};

</script>

We add the v-bottom-sheet component to show the sheet content when we click on the Open Persistent button.

The Open Persistent button should be in the activator slot to let us toggle the bottom sheet.

The v-model sets the open state of the bottom sheet.

It’ll open when it’s true .

v-model Control

We can use v-model to control the bottom sheet.

For example, we can write:

<template>

<v-container>

<v-row class="text-center">

<v-col col="12">

<div class="text-center">

<v-btn color="blue" dark @click="sheet = !sheet">Open v-model</v-btn>

<v-bottom-sheet v-model="sheet">

<v-sheet class="text-center" height="200px">

<v-btn class="mt-6" text color="red" @click="sheet = !sheet">close</v-btn>

<div class="py-3">Lorem ipsum</div>

</v-sheet>

</v-bottom-sheet>

</div>

</v-col>

</v-row>

</v-container>

</template> <script>

export default {

name: "HelloWorld",

data: () => ({

sheet: false,

}),

};

</script>

We have the Open v-model button to toggle the bottom sheet.

Photo by Rebecca Matthews on Unsplash

Conclusion

We can add a bottom sheet to display content at the bottom of the page.

It can be toggled.