Is it possible to resize vuetify components? - vue.js

I recently use Vuetify to implement some UI designs. However, I found the default input component (such as v-text-field, v-select) are too large. I found that I can adjust the width of them, but for the height and font size, how can I change them?

I have had some success using CSS transform to shrink everything:
.compact-form {
transform: scale(0.875);
transform-origin: left;
}
Just add that to your form. Its takes the font-size down to 14px (instead of 16) and shrinks the checkboxes and so on as well.

Although you can use :style bindings, to get what you want you'll have to resort to CSS.
You can use !important to "force in" your styles, but there are alternatives that can make it work without it. See demo below.
new Vue({
el: '#app'
});
#styled-input {
height: 40px;
font-size: 20pt;
}
.styled-input label[for] {
height: 40px;
font-size: 20pt;
}
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons'>
<link rel='stylesheet prefetch' href='https://unpkg.com/vuetify#1.0.13/dist/vuetify.min.css'>
<script src='https://unpkg.com/babel-polyfill/dist/polyfill.min.js'></script>
<script src='https://unpkg.com/vue/dist/vue.js'></script>
<script src='https://unpkg.com/vuetify#1.0.13/dist/vuetify.min.js'></script>
<div id="app">
<v-app id="inspire">
<v-container fluid>
<v-layout row>
<v-flex>
<v-text-field name="input-1" label="Regular Input"></v-text-field>
<v-text-field name="input-1" label="Styled Input" id="styled-input" class="styled-input"></v-text-field>
</v-flex>
</v-layout>
</v-container>
</v-app>
</div>

I believe that one should always use native vuetify way instead of just using same or stronger CSS selectors or even make some CSS transformations to change size of the whole element...
You can look up all variables in Vuetify docs (more can be found for every component):
https://vuetifyjs.com/en/api/vuetify/#sass-variables
Make sure to check how to enable possibilty to override the variables:
https://vuetifyjs.com/en/features/sass-variables/
For example you can change font-size of text field by overriding $input-font-size: 18px; variable

https://vuetifyjs.com/en/api/v-text-field/#props
add dense
<v-text-field dense></v-text-field>

You can just reference by name as follows.
In your template code:
<v-text-field
class = "inputField input-name p-3 styled-input"
label="username"
name="username"
type="text"
:state="nameState"
v-model="credentials.username"
:rules="rules.username"
color="#01579B"
box
required
/>
In your style code:
.input-name {
background-color: #ffffff;
margin-top: 10px;
}

Related

how to change the font size of label in <v-checkbox> Vuetify?

I want to change the font size of "attendance",which is the content of label.
<v-checkbox
v-model="course.evaluation"
label="attendance"
></v-checkbox>
Here is what I've tried. Inside the same vue file, I added
<style>
.v-checkbox.v-label {
font-size: 10px;
}
</style>
But it didn't work. Anyone can help?
Try increasing priority by adding chaining selectors
Add a class to the checkbox
<v-checkbox
class="my-checkbox"
v-model="course.evaluation"
label="attendance"
></v-checkbox>
Then
<style>
.my-checkbox .v-label {
font-size: 10px;
}
or In case it still doesn't reflect the override then use deep selector
::v-deep .my-checkbox .v-label {
font-size: 10px;
}
You are using wrong css selectors. You may solve your problem this way:
<style>
.v-input--checkbox .v-label {
font-size: 10px;
}
</style>
But keep in mind that if your component contain more than one v-checkboxes, all of them will have their font changed.
Another solution is to override label slot this way:
<v-checkbox
v-model="course.evaluation">
<template v-slot:label>
<span style="font-size: 10px">attendance</span>
</template>
</v-checkbox>

Remove content padding from Vuetify Parallax

How to remove padding from the content inside of a Vuetify Parallax?
<v-parallax src="https://cdn.pixabay.com/photo/2017/05/23/22/36/vegetables-2338824_960_720.jpg" style="min-height: 650px">
<v-row
no-gutters
align="center"
justify="center"
style="background-color: rgba(255, 255, 255, 0.6)"
>
</v-row>
https://codepen.io/mckraemer/full/eYORoBe
If Vuetify has not exposed some prop which you need, you can also do that overriding the CSS. In your case, you can put a style tag at the end of the HTML section just like below
<style>
.v-parallax__content {
padding: 0px !important;
}
</style>
it's working on your codepen
Just be careful, overriding the style .v-parralax_content only works if the tag is not scoped i.e.
A workaround for this is to create a global css file and override it there. Remember to point to it in your nuxt.config.js, for example:
css: [
'~/css/main.css'
],

Vuetify RadioGroup full width

i have a vuejs app which looks like this
<div id="app">
<v-app>
<v-content>
<v-container fluid>
<v-radio-group v-for="i in list" :key="i">
<v-layout row wrap>
<v-flex md4>
<v-radio label="Test 1" value="a"></v-radio>
</v-flex>
<v-flex md4>
<v-radio label="Test 2" value="b"></v-radio>
</v-flex>
<v-flex md4>
<v-radio label="Test 3" value="c"></v-radio>
</v-flex>
</v-layout>
</v-radio-group>
</v-container>
</v-content>
</v-app>
</div>
(https://codepen.io/anon/pen/NEErNz)
The Problem is that i want to have the radios in full with, but the css class v-input__control which is generated by vuetify blocks this.
Do you have any ideas how i could fix this?
Wrong -> v-input__control -> width: auto
Correct -> v-input__control -> width: 100%
Rithy awnser is almost right but it has 2 problems. The css code affects every control on app (and is not scoped) and v-input__contol class is not accesible by css or your css processor because is scoped inside de control group component. So:
Add a class to your radio group:
<v-radio-group class="radio-group-full-width" v-for="i in list" :key="i">
Then add the css styles (If you use SCSS, if not, see #JakesInTheSoup answer)
<style scoped lang="scss">
.radio-group-full-width {
>>>.v-input__control {
width: 100%
}
}
</style>
The ">>>" is important because it allows the css to access the embeded component scope
#Nacho Moco's answer worked for me with a slight modification to the braces:
<style scoped>
.radio-group-full-width >>>.v-input__control {
width: 100%
}
</style>
just apply style to overwrite existing class
<style scoped>
.v-input__control {
width: 100% !important
}
.v-label {
width: 100% !important
}
</style>
#Nacho Moco's answer worked for me with a slight modification:
<style scoped>
.radio-group-full-width >>> .v-input--radio-group__input {
justify-content: space-between;
}
</style>
Vue 3 gives an error for >>> and the suggested revision is in https://vuejs.org/api/sfc-css-features.html#scoped-css. Expected code is in the form :
<style scoped>
.a :deep(.b) {
/* ... */
}
</style>
The revised code is :
<style scoped>
.radio-group-full-width :deep(.v-input--radio-group__input) {
justify-content: space-between;
}
</style>
I achieved this with Traxo's comment. Here was my layout using Vuetify v1.5.11:
<v-radio-group v-model="selectedDate" class="radio-container d-flex">
<v-radio
class="radio-item"
color="primary"
v-for="item of items"
:key="item.id"
:value="item"
:label="'This is an individual item!'"
></v-radio>
</v-radio-group>
And my CSS:
.radio-container {
max-height: 60vh;
overflow-y: scroll;
.radio-item {
border-bottom: 0.1rem #E5E5E5 solid;
padding: 25px;
}
}

v-tabs in vuetify is not taking 100% height

The v-tabs component doesn't take 100% height. Upon inspecting, I could see that all the tab items (i.e. tab contents) are being wrapped inside a
<div class='v-tab__items'>
your content
</div>
How do target the v-tab__items class? Or is there another way to achieve the same? I have tried the height API from Vuetify, which did not yeild the desired result.
Any help is appreciated :)
Context
I'm posting an answer here since I found this question when searching to solve my own problem. In my case I wanted the tab content to occupy all the height. Which sounds similar to your problem, but since the question does not provide any specifics for the problem I will make some assumptions.
Solution
Since v-tab__items will have the height of its content, create a parent element for the content that has the desired height, in my case I use the viewport height (note that, since the tabs also have its own height, the content must take that into account). I use this in conjunction with <v-layout align-center justify-center column fill-height/>. See the following example:
new Vue({
el: '#app'
})
.tab-item-wrapper {
/* vuetify sets the v-tabs__container height to 48px */
height: calc(100vh - 48px)
}
<link href="https://cdn.jsdelivr.net/npm/vuetify#1.2.6/dist/vuetify.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify#1.2.6/dist/vuetify.min.js"></script>
<div id="app">
<v-app>
<v-tabs>
<v-tab>tab</v-tab>
<v-tab-item>
<div class="tab-item-wrapper">
<v-layout align-center justify-center column fill-height>
<v-btn color="success">Success</v-btn>
<v-btn color="error" outline>Error</v-btn>
</v-layout>
</div>
</v-tab-item>
</v-tabs>
</v-app>
</div>
Note: I could not find a solution to avoid hardcoding the tab-height, by the time being this is hardcoded on Vuetify styles it's not exposed as a variable.
EDIT Updated snippet starting tag for v-layout was self closing.
This works for me in Vuetify 2.
.v-tabs-items.full-height-tab .v-window-item {
height: calc(100vh - 270px); /* Adjust 270px to suits your needs */
overflow-y: auto;
}
<v-tabs-items class="full-height-tab">
<v-tab-item>...</v-tab-item>
<v-tab-item>...</v-tab-item>
</v-tabs-items>
Context
I found this question while trying to solve the same problem as #a--m did but their solution does not respect a single source of truth principle. If v-tabs height changes in the future Vuetify versions, the layout will stop working as expected, and calc() will be needed to be rewritten. Logically, our tab items should know nothing about header height.
Moreover, v-tab-item should not be inside v-tabs but in a separate v-tabs-items component.
My solution
Generally it is not a Vuetify issue but a pure CSS problem. It can be solved just with flexboxes and overflow property, even when the parent height is computed.
Please see my answer in more specialized thread and the adapted JSFiddle example with v-tabs.
The only difference in this specific case is a need to use !important modifier when you set overflow: auto on v-tabs-items.
I was looking for 2 hours. But I found
.tabs__content
{
min-height: 100vh;
}
Simple solution for Vuetify 2.3.10:
In the component containing <v-tabs>, <v-tab> and <v-tab-item>, add this to your style:
.v-window__container {
min-height: 100vh;
}
You can a CSS selector in your single-file component with a larger specificity
<style>
.my-component .v-tab__items
{
height: 100%;
}
</style>

Change font-size of <v-radio> vuetify

I am newly using vuetify. I want to change font-size of <v-radio> button and its label. Directly applying css not working. So i searched for some answer, but those answer are very short. Which i'm unable to apply them. Can anyone help me to explain how do i change font-size in vuetify? TIA
Updated:
<template>
<v-flex xs6>
<p class="title-input">Jenis Kelamin</p>
<v-radio-group id="id-gender" class="no-space" v-model="genderSelect" :mandatory="false" row #change="genderAction">
<v-radio class="gender" label="Pria" value="Pria"></v-radio>
<v-radio class="gender" label="Wanita" value="Wanita"></v-radio>
</v-radio-group>
<span class="text-error" v-show="genderError">Mohon diisi</span>
</v-flex>
</template>
<style scoped src="../style/Shortform.css">
</style>
Got the answer. In my css file all i have to do is
.customClass >>> label
adding those >>> icon solved the problem.
If you want to use a style tag in the .vue file you have the option to remove scoped from the style tag and target the label directly.
<style>
.v-label {
font-size: desired size
}
</style>
If it happens that you have a separate .css file you can still use this method and ignore the <style> tag
.v-label {
font-size: desired size
}
This worked for me:
.small-radio i {
font-size: 19px;
}
.small-radio label {
font-size: 14px;
padding-left: 0px;
margin-left: -4px;
}
.small-radio .v-radio {
padding: 0px;
}
.small-radio [class*="__ripple"] {
left: 0;
}
Add v-deep:: infront if requred.
Add the style to v-radio-group:
<v-radio-group class="small-radio" v-model="radioGroup">
<v-radio
...
></v-radio>
</v-radio-group>