I would like to center my title in my toolbar component. This is what it's looke like :
And this is my component :
<div>
<v-navigation-drawer dark app clipped temporary v-model="menu" class="teal white--text">
<v-list >
<v-list-tile
v-for="(item,index) in items" :key="index" @click="$router.push(item.path)" v-if="item.value">
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>{{ item.label }}</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar dense dark color="teal" class="pa-0">
<router-link to="/">
<v-btn class="mx-0" icon>
<i class="material-icons">home</i>
</v-btn>
</router-link>
<v-toolbar-title class="white--text">{{title}}</v-toolbar-title>
<v-layout align-center justify-end>
<v-toolbar-items>
<router-link to="/parametres">
<v-btn class="mx-0" icon>
<i class="material-icons">settings</i>
</v-btn>
</router-link>
<v-btn v-on:click="Logout()" class="mx-0" icon>
<i class="material-icons">exit_to_app</i>
</v-btn>
</v-toolbar-items>
</v-layout>
</v-toolbar>
</div>
I can not center it properly in relation to the toolbar. Maybe should i use flex properties ? By the way i'm using Vuetify.js for the material design.
If you can help me I'll be grateful. I'm totally new with flex and vuejs.
In my case, I had only <v-toolbar-title>
, so I had to put <v-spacer />
both on the right and left of it:
<v-toolbar>
<v-spacer />
<v-toolbar-title>
Some title text
</v-toolbar-title>
<v-spacer />
</v-toolbar>
Add a v-spacer
before the title
<v-spacer></v-spacer>
<v-toolbar-title class="white--text">{{title}}</v-toolbar-title>
A more complex alternative would be to use the grid layout with flex spacing
<v-toolbar dense dark color="teal" class="pa-0">
<v-row>
<v-col cols="2">
...
</v-col>
<v-col class="d-flex justify-space-around">
<v-toolbar-title class="white--text">{{title}}</v-toolbar-title>
</v-col>
<v-col cols="2" class="d-flex justify-end">
...
</v-col>
</v-toolbar>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With