How can I align content to right inside v-col? - vuetify.js

In the document, justify-** and align-** are design for determine where the grid block should be placed, but how can I make the content inside the v-col align to right?

Here is a small example that aligns content to the right inside v-col (in this case a close button):
<v-row>
<v-col align="right">
<v-btn color="error">X</v-btn>
</v-col>
</v-row>
Or with multiple columns:
<v-row>
<v-col cols="9">
<h2>Title</h2>
</v-col>
<v-col cols="3" align="right">
<v-btn color="error">X</v-btn>
</v-col>
</v-row>
So you simply need to add
align="right"
as a parameter at v-col to align content to the right side within a v-col.

Bit late to this. I came here for a solution and ended up RTM. align="right" doesn't work for all components inside v-col. The way to left/right/center align is to use v-spacer. If you want to right align, add a v-spacer to the left of your component inside of v-col. v-col also needs d-flex class.
<v-app>
<v-container>
<v-row>
<v-col cols="8">
</v-col>
<v-col class="d-flex" cols="4">
<v-spacer />
<!-- insert any other content here to right align inside this col -->
</v-col>
</v-row>
</v-container>
<v-app>
You can also add the class .text-right if you're trying to align a button or text

According to the code of the Playground example in Vuetify's Grid System page, you could put an EXTRA v-row inside your v-col, and use justify-** in this newly added v-row. E.g.:
<v-app>
<v-container>
<v-row>
<!-- first column -->
<v-col cols="8">
<!-- the extra row -->
<v-row justify="center">
<p>Your Content</p>
</v-row>
</v-col>
<v-col cols="4">
Second column
</v-col>
</v-row>
</v-container>
<v-app>
Or, if the v-col is the ONLY column in your first-level v-row, you MAY get rid of that, just put your content in the v-row to which you can apply the justify. E.g.:
<v-app>
<v-container>
<v-row justify="center">
<p>Your Content</p>
</v-row>
</v-container>
<v-app>

Related

Vuetify problems with the width of a v-col

I would like to set the v-col width with the h1, in the code below, to 100% of the page, how can i do it?
<v-main class="pt-0 black" max-width="auto">
<v-row>
<v-col cols="auto">
<v-img src="#/assets/images/riot-logo.png"></v-img>
</v-col>
<v-col cols="auto">
<v-container class="riot-text">
<h1 class="text-center">Riot Games</h1>
</v-container>
</v-col>
</v-row>
</v-main>
</template>
The columns are adjacent to one another, so you can't make one 100% without setting the other to zero. In order to set the column to width 100%, you will need to place each column in it's own row. I also removed the cols="auto" attribute.
<v-main class="pt-0" max-width="auto">
<v-row>
<v-col cols="auto">
<v-img src="#/assets/images/riot-logo.png"></v-img>
</v-col>
</v-row>
<v-row>
<v-col>
<v-container class="riot-text fluid">
<h1 class="text-center">Riot Games</h1>
</v-container>
</v-col>
</v-row>
</v-main>

why under v-row and v-col vuetify always align center

can any body help, why in vuetify under v-col always align center ?
i try to make simple paragraph, but why always align center ?
here is my code
<v-container>
<v-row>
<v-col cols="12" md="8">
<p>test paragraph</p>
</v-col>
<v-col cols="12" md="4">
<p>test kedua</p>
</v-col>
</v-row>
</v-container>

How to select to make v-textfield read-only?

for my model, I use a v-select and a v-text field for when a selected value makes v-textfield read-only, but how is this implemented in vuetify?
<template>
<v-container>
<v-row>
<v-col cols="12" sm="3" md="3">
<v-select
:items="['Yes','No']"
label="select"
></v-select>
</v-col>
<v-col cols="12" sm="3" md="3">
<v-text-field
label="ReadOnly"
></v-text-field>
</v-col>
</v-row>
</v-container>
</template>
Store the selected value of the v-select, then control the readonly prop of the v-select based on the selected value. I assume that when you selected "yes", the textfield will be readonly
<v-select
v-model="selected"
:items="['Yes','No']"
label="select"
></v-select>
...
<v-text-field
label="ReadOnly"
:readonly="selected === 'yes'"
></v-text-field>
Here's a sample demo at codesandbox:

Vuetify 2.2, Why my footer is not aligned at absolute bottom on the Code Pen?

I have a code pen inside this code pen I have vuetify 2.2.15.
I've used footer as follow:
<div id="app">
<v-app>
<v-content>
<v-container>
<v-card>
<v-card-text>
Expected to align at bottom
</v-card-text>
</v-card>
</v-container>
<v-content>
<v-footer>
<v-col
class="text-center"
>
footer
</v-col>
</v-footer>
</v-app>
</div>
In the real code running on the web, this footer is aligned at the absolute bottom. But in the code pen, the footer is NOT aligned at the absolute bottom, but just follow the previous component relatively.
Is there any missing stack I should have used? Thank you for your suggestion.
you should use absolute in your v-footer like:
<v-footer absolute>
<v-col class="text-center">
footer
</v-col>
</v-footer>
absolute prop applies position: absolute to the component.
also you should move </v-content> after your footer
your final code should be like:
<div id="app">
<v-app>
<v-content>
<v-navigation-drawer app></v-navigation-drawer>
<v-container>
<v-card
>
<v-card-text
>
Expected to align at bottom
</v-card-text>
</v-card>
</v-container>
<v-footer absolute>
<v-col
class="text-center"
>
footer
</v-col>
</v-footer>
</v-content>
</v-app>
</div>

Make columns same height in Vuetify Grid System

I'm currently creating a grid-layout in Vuetify, but I got stuck. I'm making a card-layout containing images. Here is the example:
I've tried it with the following code, but then small cards on the right are not aligned due to the margins.
<v-container>
<v-row class="justify-center">
<v-col cols="6">
<v-hover v-slot:default="{ hover }">
<v-card
to="/pools"
:elevation="hover ? 12 : 2"
:class="{ 'on-hover': hover , 'overwrite-hover' : $vuetify.breakpoint.xsOnly}"
>
<v-img class="white--text" :src="images[0]">
<v-card-title class="white--text align-end fill-height headline">My Pools</v-card-title>
<template v-slot:placeholder>
<v-row class="fill-height" align="center" justify="center">
<v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
</v-row>
</template>
</v-img>
</v-card>
</v-hover>
</v-col>
<v-col cols="2">
<v-card class="ma-2" light height="50%"></v-card>
<v-card class="ma-2" light height="50%"></v-card>
</v-col>
</v-row>
<v-row class="justify-center">
<v-col cols="8">
<v-card light height="120px"></v-card>
</v-col>
</v-row>
</v-container>
Does anyone have a suggestion, or maybe a similar example?
Thanks in advance!
Luckily you only need to make minor adjustments to the smaller cards on the right. Make use of flex and let flex do its magic :) It's basically telling the cards to grow to the maximum height available without clipping. Then add some margin in between the cards with the helper classes mb and mt.
<v-col cols="2" class="d-flex" style="flex-direction:column">
<v-card class="mb-1 flex-grow-1">
Upper card
</v-card>
<v-card class="mt-1 flex-grow-1">
Lower card
</v-card>
</v-col>
As a codesandbox. Check out the file "layout.vue" for the complete example.

Resources