Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify - Center content in v-list-tile-content

I am trying to center the content inside a v-list-tile-content of a v-list without success. I've tried to apply text-xs-center, justify-center to the v-list element and the v-list-tile-content and it does not work. Also I've tried to put a div inside the v-list-tile-content and apply the previously mentioned classes. I've found that the v-list-tile-content element has a align-items: flex-start and if I delete that it automatically apply the classes.

As far as I know align-items it's for vertical alignment and for horizontal alignment the proper class is justify-items, am I right?

<v-list class="table pa-0">
    <v-list-tile
        v-for="(element, index) in elements"
        :key="`pricing_table_element_${index}`"
        :class="{'dark-background': index % 2 === 0}"
        avatar
    >
        <v-list-tile-avatar>
            <fa-icon
            icon="check-circle"
            color="#00BB9B"
            />
        </v-list-tile-avatar>

        <v-list-tile-content>
            {{ element.content }}
        </v-list-tile-content>

        <v-list-tile-action>
            <v-tooltip right>
                <fa-icon
                    slot="activator"
                    icon="info-circle"
                    color="#f68e28"
                />
                <span>{{ element.tooltip }}</span>
            </v-tooltip>
        </v-list-tile-action>
    </v-list-tile>
</v-list>
like image 781
SiliconMachine Avatar asked Jan 30 '19 16:01

SiliconMachine


People also ask

What is V list tile?

The v-list component is used to display information. It can contain an avatar, content, actions, subheaders and much more. Lists present content in a way that makes it easy to identify a specific item in a collection. They provide a consistent styling for organizing groups of text and images.

What is v spacer?

v-spacer. v-spacer is a basic yet versatile spacing component used to distribute remaining width in-between a parents child components.


2 Answers

As I wanted to use the Vuetify native classes but they had not the !important and the align-items: start of the v-list was overwriting my aling-center, I just added an inline style as follows:

<v-list-tile-content
  :style="{
    'align-items':'center'
  }"
>
  {{ element.content | capitalizeFirstLetter }}
</v-list-tile-content>

This was the solution that I was searching for. Hope it helps.

like image 119
SiliconMachine Avatar answered Oct 11 '22 21:10

SiliconMachine


If you use all of these CSS rules on one of the Vuetify example list codepens, it aligns the list item text center. (If you don't have a second line, you don't need the flex-direction: row part.)

.v-list__tile__content{
    justify-content: center!important;
    flex-direction: row!important;
    text-align: center!important;
    align-items: center!important;
}

.v-list__tile__title, .v-list__tile__sub-title {
    text-align: center!important;
}
like image 25
LShapz Avatar answered Oct 11 '22 21:10

LShapz