Home  >  Q&A  >  body text

Align elements to sides in vuetify3 block button: guide

<p>Suppose I have the following button: </p> <pre class="brush:php;toolbar:false;"><v-btn block size="x-large"> <v-btn icon size="small" variant="contained"> <v-icon>mdi-information</v-icon> </v-btn> Button Text <v-icon>mdi-check</v-icon> </v-btn></pre> <p>The icons on the left and right are sandwiched with the text. How can I place them on the right and left edges of the button respectively? I've tried using <code>v-spacer</code>s but it doesn't work. I also tried using <code>v-row</code> in the button, but that didn't help as the items became even more misaligned. </p>
P粉680000555P粉680000555416 days ago433

reply all(1)I'll reply

  • P粉573809727

    P粉5738097272023-08-31 09:16:31

    You can align items horizontally using the justify property.

    Live Demo:

    new Vue({
      el: '#app',
      vuetify: new Vuetify()  
    })
    <script src="https://unpkg.com/vue@2.x/dist/vue.js"></script>
    <script src="https://unpkg.com/vuetify@2.6.10/dist/vuetify.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/vuetify@2.6.10/dist/vuetify.min.css"/>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"/>
    <link rel="stylesheet" href="https://unpkg.com/@mdi/font@6.x/css/materialdesignicons.min.css"/>
    <div id="app">
      <v-app id="inspire">
        <v-btn block size="x-large">
          <v-row justify="space-between">
            <v-col md="4">
              <v-btn icon size="small" variant="contained">
                <v-icon>mdi-information</v-icon>
              </v-btn>
            </v-col>
            <v-col>Button Text</v-col>
            <v-col md="4">
              <v-btn icon size="small" variant="contained">
                <v-icon>mdi-check</v-icon>
              </v-btn>
            </v-col>
          </v-row>
        </v-btn>
      </v-app>
    </div>

    reply
    0
  • Cancelreply