admin管理员组文章数量:1401184
I need to align the Vuetify ponent vertically and horizontally
Versions
vue 2.6.10 vuetify 2.1.10
This is the current code of the ponent Snackbar
<v-snackbar
class="no-shadow"
v-model="snackbarShow"
:color="snackbarType"
:timeout="snackbarTimeout"
>
<v-icon class="mr-3">{{ snackbarIcon }}</v-icon>
<div>{{ snackbarText }}</div>
<v-btn text icon color="white" @click="snackbarShow = false">
<v-icon color="white">mdi-close-circle</v-icon>
</v-btn>
</v-snackbar>
I need to align the Vuetify ponent vertically and horizontally
Versions
vue 2.6.10 vuetify 2.1.10
This is the current code of the ponent Snackbar
<v-snackbar
class="no-shadow"
v-model="snackbarShow"
:color="snackbarType"
:timeout="snackbarTimeout"
>
<v-icon class="mr-3">{{ snackbarIcon }}</v-icon>
<div>{{ snackbarText }}</div>
<v-btn text icon color="white" @click="snackbarShow = false">
<v-icon color="white">mdi-close-circle</v-icon>
</v-btn>
</v-snackbar>
Share
Improve this question
asked Oct 2, 2020 at 16:45
Jorge GaticaJorge Gatica
1091 gold badge4 silver badges8 bronze badges
2 Answers
Reset to default 5v2
<v-snackbar centered />
v3
<v-snackbar v-model="snackbar" timeout="5000" location="center">
The reason a snackbar is difficult to align vertically is basically because it is not designed to do this. Vuetify is just one implementation of Google's Material Design specification. Personally, I love Vuetify and use it a lot, but remember it's just a ponent library, so their documentation primarily focuses on how to use the ponents, with no guidance on which ponent to use or when you should or shouldn't use a particular ponent. That's why I always reference material.io for that information, to make sure I'm not just piecing together material ponents in a way that breaks material design rules.
As you can see here: https://material.io/ponents/snackbars snackbars are specifically supposed to be at the bottom of the screen.
To get the style you're after, the UI ponent you want in the Vuetify library is v-dialog
. https://vuetifyjs./en/ponents/dialogs/
At its heart, it just centers a ponent (usually a card) horizontally and vertically, while providing an easy way to bind its visibility to a prop and even gives you a hide-overlay
prop. So using that ponent, you could get the style you're after, pretty much 'out of the box.'
Just make sure that placing a ponent in the dead center of the UI doesn't make for a bad UX. Material.io has some excellent guidance in picking the right ponent for the right task: https://material.io/ponents/dialogs#usage
本文标签: javascriptHow to align Vuetify snackbar component vertically to the centerStack Overflow
版权声明:本文标题:javascript - How to align Vuetify snackbar component vertically to the center? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744261636a2597743.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论