The goal is to be able to resize a v-dialog
on click of a button.
Usually I can apply dynamic css classes to vuetify components via :class
prop.
However, v-dialog
requires use of the content-class
in order to apply css class to it.
How can I accomplish something like code below on a v-dialog:
<v-dialog
persistent
scrollable
v-model="dialog"
:class="{ 'my-css-class-name': myBooleanFlag }"
style="position: relative;"
>
CodePudding user response:
Try with :content-class="myBooleanFlag ? 'my-css-class-name' : ''"
:
new Vue({
el: '#app',
vuetify: new Vuetify(),
data() {
return {
myBooleanFlag: true,
dialog: true
}
}
})
.my-css-class-name {
background: violet;
height: 100px;
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
<div data-app id="app">
<v-dialog
persistent
scrollable
v-model="dialog"
:content-class="myBooleanFlag ? 'my-css-class-name' : ''"
style="position: relative;"
>
<button @click="myBooleanFlag = !myBooleanFlag">click</button>
</div>