Search code examples
vuetify.jsv-btn

vuetify v-btn with text-truncate


Any one know how to use text-truncate with v-button. My current attempts are this:

enter image description here

<v-menu
  offset-y>
  <template v-slot:activator="{on, attrs}">
    <v-btn
      text
      v-bind="attrs"
      v-on="on"
      :max-width="150"
      class="text-truncate"
      ><span class="text-truncate;max-width:150px">{{ userEmail }}</span></v-btn>
  </template>
  <v-list>
    <v-list-item-group>
    <v-list-item
      v-for="(item, index) in personalMenuItems"
      :key="index"
      @click="item.action">
      <v-list-item-title>{{ item.title }}</v-list-item-title>
    </v-list-item>
  </v-list-item-group>
 </v-list>
</v-menu>

Solution

  • Make sure your properly setting the max-width style...

    <v-btn text v-bind="attrs"
        v-on="on"
       :max-width="150">
       <span class="text-truncate" style="max-width:150px">{{ userEmail }}</span>
    </v-btn>
    

    Demo