Vuetify Scrollable Dialog

Vuetify Scrollable Dialog:In this tutorial, we will create a scrollable dialog using Vuetify. A scrollable dialog can be particularly useful when you have a long list of options to display in a dialog box. In this example, we will create a dialog that allows users to select a country from a list of options.

Profile Photo

Abhishek Yadav (SD) SDE of FAI

Feedback

written
Profile Photo

Anil Kumar (Expert) Coding Expert of FAI

Feeback

reviewed
Profile Photo
Oct 31, 2023 02:10 AM Last Updated
updated

Vuetify Scrollable Dialog Code

First, let's take a look at the code for the Vuetify Scrollable Dialog:

Vuetify Scrollable Dialog Example

Copied to Clipboard
Run

In this code snippet:

  • We use the <v-card> component to create a card with a title "Vuetify Scrollable Dialog."

  • Inside the card's content, we use a <v-dialog> component to create the dialog. The scrollable attribute allows the dialog's content to be scrollable when it exceeds the specified height. We set a max-width of 300px for the dialog.

  • The "Open Dialog" button that triggers the dialog is created using a <v-btn> component. We use a template to bind the attrs and on properties to the button.

  • Inside the dialog, we have a card containing a title "Select Country" and a scrollable list of countries represented by <v-radio> components.

  • We also include "Close" and "Save" buttons within the dialog's actions, which allow you to close the dialog

 

JavaScript Code

To handle the dialog's state and selected country, we use the following JavaScript code

Copied to Clipboard

This code initializes a Vue instance, sets up Vuetify, and defines the data properties dialogm1 and dialog. The dialog property controls the visibility of the dialog, and dialogm1 stores the selected country.

Output of Vuetify Scrollable Dialog

Pasted Image

Conclusion

In this tutorial, we created a Vuetify Scrollable Dialog using Vuetify's components and Vue.js. The dialog allows users to select a country from a scrollable list. You can further customize and extend this example to suit your application's needs. Vuetify makes it easy to create stylish and functional dialogs and other UI components for your web projects

Ad