Vuetify works dodgy in Nuxt.js project - vue.js

I am facing some weird issue.
Vuetify has limited functionality in my nuxt.js project.
First of all here's my default layout:
<div>
<NavBar />
<Nuxt />
</div>
</template>
And the NavBar component overlays the page.
However the problem disappears if I remove the app prop from <v-app-bar app flat> but then the NavBar won't be always on top of the page.
See screenshots for details:
Default view:
View with margin-top: 100px; on lorem
The code of NavBar components:
<template>
<nav>
<v-app-bar app flat>
<v-app-bar-nav-icon
x-large
class="grey--text"
#click="drawer = !drawer"
/>
<v-spacer />
<v-toolbar-title>
LOGO
</v-toolbar-title>
<v-spacer />
<v-menu offset-y>
<template #activator="{ on, attrs }">
<v-btn text v-bind="attrs" v-on="on">
<!-- <v-icon>expand_more</v-icon> -->
Dropdown menu
</v-btn>
</template>
<v-list>
<v-list-item v-for="contact in contacts" :key="contact.i">
<v-list-item-action>
<a :href="contact.link">
<v-icon>
{{ contact.icon }}
</v-icon>
</a>
</v-list-item-action>
<v-list-item-content>
<a :href="contact.link">
<v-list-item-title>
{{ contact.name }}
</v-list-item-title></a
>
</v-list-item-content>
</v-list-item>
</v-list>
</v-menu>
</v-app-bar>
<v-navigation-drawer v-model="drawer" bottom temporary app>
<v-list>
<v-list-item
v-for="link in links"
:key="link.i"
router
:to="link.route"
#click="refresh"
>
<v-list-item-action>
<v-icon>{{ link.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
<span> {{ link.name }} </span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
</nav>
</template>
<script>
export default {
data() {
return {
drawer: false,
}
},
computed: {
links() {
return this.$store.state.routes
},
contacts() {
return this.$store.state.contacts
},
},
methods: {
refresh() {
if (this.drawer) {
this.drawer = !this.drawer
}
},
},
}
</script>
<style></style>
As you can see the NavBar covers part of the content.
And another problem is that class="mt-5 pt-5" or any other classes about margin or padding doesn't work. class="d-flex" doesn't work too.
And as you can see on the screenshot, there's a class="ml-5 pl-5 d-flex" But there's no margin left, no padding left and the container is not flex.
However
:class="{
'tiny': $vuetify.breakpoint.smAndDown,
'large': $vuetify.breakpoint.mdAndUp,
}"
and
<style>
.tiny {
font-size: 1rem;
color: red;
}
.large {
font-size: 2rem;
color: green;
}
</style>
Does work.
And I am really confused about vuetify in nuxt.js

Erasing and creating a new Nuxt.js project somehow helped with not working vuetify.
About margin:
The issue been solved by including NavBar (the code itself) into a default.vue layout AND nesting components in there.
For some reason it doesn't work well if I nest it this way in the layouts/default.vue:
<NavBar />
<Nuxt />
<Footer />
So the layouts/default.vue looks like this and it does work just fine:
<template>
<v-app dark>
<v-navigation-drawer v-model="drawer" bottom :fixed="fixed" app>
<v-list>
<v-list-item
v-for="route in routes"
:key="route.i"
:to="route.to"
router
exact
#click="refresh"
>
<v-list-item-action>
<v-icon>{{ route.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title v-text="route.title" />
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar :fixed="fixed" app flat>
<v-app-bar-nav-icon #click.stop="drawer = !drawer" />
<v-spacer />
<NuxtLink to="/">LOGO</NuxtLink>
<v-spacer />
<span> +34XX-XXX-XX-XX </span>
<DropdownWithContacts />
</v-app-bar>
<v-main>
<Nuxt /> <!-- the nuxt view -->
</v-main>
<v-spacer></v-spacer>
<Footer />
</v-app>
</template>
<script>
export default {
data() {
return {
drawer: false,
fixed: true,
}
},
computed: {
routes() {
return this.$store.state.menu.routes
},
},
methods: {
refresh() {
if (this.drawer) {
this.drawer = !this.drawer
}
},
},
}
</script>
<style>
/*a normal, unvisited link*/
a:link {
color: green;
}
/*a link the user has visited*/
a:visited {
color: purple;
}
/*a link when the user mouses over it*/
a:hover {
color: yellow;
}
/*a link the moment it is clicked*/
a:active {
color: brown;
}
/* removed underline */
a {
text-decoration: none;
}
</style>
And I am really finding this weird. But I guess this is just the way it works.

Related

How can i change my v-list background color?

I can't figure out why my v-list won't update the color whatever i do.
here is my code
<template>
<v-app>
<v-navigation-drawer app>
<div style="background-color: grey;" class="d-flex justify-center pa-4 ">
Fichiers chargés
</div>
<div class="d-flex flex-column ">
<v-btn prepend-icon="mdi-folder" class="mt-4 mb-2 mx-auto text-black bg-green hidden-sm-and-down"
plain>Parcourir
..</v-btn>
<v-checkbox class="mx-auto" label="Ajout auto. en base"></v-checkbox>
</div>
<v-divider></v-divider>
<v-list class="my-list" color="primary" >
<v-list-tile v-for=" f in fichiers">
<v-card-text class=" mx-5 px-5 bg-red">
{{ f.nom }}
</v-card-text>
</v-list-tile>
<v-divider></v-divider>
<v-list-item style="width: 0100%;">
<div style="text-align: center;">
{{ fichiers.length }} Fichiers Chargés
</div>
</v-list-item>
</v-list>
</v-navigation-drawer>
</v-app>
</template>
<style>
.my-list {
background-color: red;
}
</style>
<script setup>
let fichiers = [
{
nom: "Fichier1",
taille: "2ko",
contenu: "jhbjm",
etat: [],
}
]
</script>
in my devtools i can see that the v-list took the bg-transparent. I tried everything to force it but nothing happened
sorry for my bad english XD
The Solution :
Don't forget to give a feedback.
Use "!important" in your "background-color" value
.my-list {
background-color: red !important;
}
Use the "id" selector if you don't want to use "!important"
#the-list {
background-color: red;
}
<v-list id="the-list" color="primary" >
<v-list-tile v-for=" f in fichiers">
...
</v-list-item>
</v-list>
The reason of your problem :
If you look at the browser developer tool, you'll find that the class "v-list" is written before your custom class "my-list". That means, the priority is not for your custom class.

v-navigation-drawer takes up the entire row

my v-navigation-drawer takes up the entire row, so the content goes underneath the drawer. I was trying to research online but didn't find anything about it. I am very new to Vuetify. Please help. If you look at the screenshot the Dashboard must be next to drawer but it goes underneath. I have two components Navbar and Drawer. I render them inside of my App.vue. I attached the code below.
App.vue
<template>
<v-app>
<navbar/>
<drawer/>
<v-content>
<h1>Dashboard</h1>
</v-content>
</v-app>
</template>
<script>
import Drawer from './components/Drawer';
import Navbar from './components/Navbar';
export default {
name: 'App',
components: {
Drawer,
Navbar,
},
data: () => ({
}),
method:() => ({})
};
</script>
<style>
</style>
Navbar.vue
<template>
<div>
<nav>
<v-toolbar class="cyan lighten-1" dark prominent height="65">
<v-toolbar-title class="text-uppercase gray--text">
<span class="font-weight-light">Stock</span>
<span>Dashboard</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn text color="black">
<span>Log Out</span>
<v-icon right>exit_to_app</v-icon>
</v-btn>
</v-toolbar>
</nav>
</div>
</template>
<script>
export default {
data(){
return {
}
}
}
</script>
<style>
</style>
Drawer.vue
<template>
<v-navigation-drawer id="app-drawer" class="cyan lighten-1" dark permanent>
<v-list>
<v-list-tile avatar>
<v-list-tile-avatar color="white">
<v-img :src="require('../assets/bull.svg')" height="70" contain class="cyan darken-5"></v-img>
</v-list-tile-avatar>
</v-list-tile>
<v-list-item
v-for="item in items"
:key="item.title"
link
>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
<template v-slot:append>
<div class="pa-2">
<v-btn block>Logout</v-btn>
</div>
</template>
</v-navigation-drawer>
</template>
<script>
export default {
data () {
return {
items: [
{ title: 'Dashboard', icon: 'dashboard' },
{ title: 'Account', icon: 'account_box' },
{ title: 'Admin', icon: 'gavel' },
],
}
},
}
</script>
<style>
</style>
Use "app" in v-navigation-drawer like so :
<v-navigation-drawer id="app-drawer" class="cyan lighten-1" dark permanent app>
Further take a look at https://vuetifyjs.com/en/components/navigation-drawers API and use v-app-bar instead of v-toolbar for the main toolbar of your page.

How can I use bottom navigation and navigation drawers together? v-app doesn't work

I am new to vuetify and vue, I want to create a layout in which the users with sm or smaller screens will use the bottom-navigation component and the users with md or higher will use the navigation drawers.
I am using the v-app component, that according to the docs "help bootstrap your application with the proper sizing around component" and "These (components) can be mixed and matched and only one of each particular component should exist at any time."
<template>
<v-app>
<v-navigation-drawer app>
<v-list rounded>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-navigation-drawer>
<v-app-bar app>
<v-toolbar-title class="headline text-uppercase">
<span>Vuetify</span>
<span class="font-weight-light">MATERIAL DESIGN</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn text href="https://github.com/vuetifyjs/vuetify/releases/latest" target="_blank">
<span class="mr-2">Latest Release</span>
</v-btn>
</v-app-bar>
<v-content fluid>
<HelloWorld />
</v-content>
<v-bottom-navigation app>
<v-btn value="recent">
<span>Recent</span>
<v-icon>history</v-icon>
</v-btn>
<v-btn value="favorites">
<span>Favorites</span>
<v-icon>favorite</v-icon>
</v-btn>
<v-btn value="nearby">
<span>Nearby</span>
<v-icon>place</v-icon>
</v-btn>
</v-bottom-navigation>
</v-app>
</template>
<script lang="ts">
import Vue from "vue";
import HelloWorld from "./components/HelloWorld.vue";
export default Vue.extend({
name: "App",
components: {
HelloWorld
},
data: () => ({
item: 1,
items: [
{ text: "Real-Time", icon: "mdi-clock" },
{ text: "Audience", icon: "mdi-account" },
{ text: "Conversions", icon: "mdi-flag" }
]
})
});
</script>
So the documentation it's perhaps a bit unclear from the text.
It's up to you to display them as you see fit. But you should for example not have two v-app-bars visible at the same time.
So here is the solution:
<template>
<v-app>
<v-navigation-drawer app v-model="$vuetify.breakpoint.mdAndUp" stateless class="hidden-sm-and-down">
<v-list rounded>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-navigation-drawer>
<v-app-bar app class="hidden-sm-and-down">
<v-toolbar-title class="headline text-uppercase">
<span>Vuetify</span>
<span class="font-weight-light">MATERIAL DESIGN</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn text href="https://github.com/vuetifyjs/vuetify/releases/latest" target="_blank">
<span class="mr-2">Latest Release</span>
</v-btn>
</v-app-bar>
<v-content fluid>
<HelloWorld />
</v-content>
<v-bottom-navigation app class="d-flex d-md-none">
<v-btn value="recent">
<span>Recent</span>
<v-icon>history</v-icon>
</v-btn>
<v-btn value="favorites">
<span>Favorites</span>
<v-icon>favorite</v-icon>
</v-btn>
<v-btn value="nearby">
<span>Nearby</span>
<v-icon>place</v-icon>
</v-btn>
</v-bottom-navigation>
</v-app>
</template>
<script lang="ts">
import Vue from "vue";
import HelloWorld from "./components/HelloWorld.vue";
export default Vue.extend({
name: "App",
components: {
HelloWorld
},
data: () => ({
item: 1,
items: [
{ text: "Real-Time", icon: "mdi-clock" },
{ text: "Audience", icon: "mdi-account" },
{ text: "Conversions", icon: "mdi-flag" }
]
})
});
</script>

v-btn 'to' prop adds path to base url (localhost), how can I direct to another website?

I'm using a Vue.js project setup with Nuxt and Vuetify.js.
I'm trying to add FontAwesome icons as v-btns to lead the user to an Instagram page.
Unfortunately when clicking the icon, the browser is directed to http://localhost:3000/https://www.instagram.com/therock/?hl=en instead of just https://www.instagram.com/therock/?hl=en as expected. The Instagram account URL is tacked onto the end of the base URL.
Here's the template portion of the Vue file:
<template>
<v-app>
<v-toolbar app flat color="rgb(249, 249, 249)">
<router-link to="/" class="toolbar-title">
<v-toolbar-title>Chumiest Bucket</v-toolbar-title>
</router-link>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-sm-and-down">
<v-btn
v-for="(item, index) in items"
:key="index"
:to="item.path"
flat
>{{ item.name }}</v-btn>
<v-btn flat :to="instagram.path">
<font-awesome-icon :icon="instagram.icon"/>
</v-btn>
</v-toolbar-items>
<v-menu class="hidden-md-and-up">
<v-toolbar-side-icon slot="activator"></v-toolbar-side-icon>
<v-list>
<v-list-item v-for="(item, index) in items" :key="index">
<v-btn :to="item.path" flat>{{ item.name }}</v-btn>
</v-list-item>
<v-btn flat :to="instagram.path">
<font-awesome-icon :icon="instagram.icon"/>
</v-btn>
</v-list>
</v-menu>
</v-toolbar>
<v-content style="padding-top: 19px;">
<v-container>
<nuxt />
</v-container>
</v-content>
<v-footer app style="position: absolute;">
<span style="font-size: 8pt;">© 2019 Chumiest Bucket</span>
</v-footer>
</v-app>
</template>
here's the script portion of the Vue file:
<script>
export default {
name: 'app',
data() {
return {
fixed: false,
items: [
{
name: 'About',
path: '/about'
},
{
name: 'Stuff',
path: '/stuff'
}
],
instagram: {
icon: ['fab', 'instagram'],
path: 'https://www.instagram.com/therock/?hl=en'
},
}
}
}
</script>
The "to" prop is used for navigating to pages within your routes. See documentation here. To navigate to external links, Bind the url to href instead.
<a :href="instagram.path">
{{ url }}
</a>

Vuetify styles tags are not appeared in my web page

I am working with Vuetify and try to make a web page but the vuetify components stylings are not appeared. Could you guide me. Thank you.
My code below.
<template>
<v-app>
<v-navigation-drawer v-model="sidebar" app>
<v-list>
<v-list-tile v-for="item in menuItems" :key="item.title" :to="item.path" #click>
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>{{ item.title }}</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar color="indigo" dark fixed app>
<v-toolbar-side-icon #click.stop="drawer = !drawer"></v-toolbar-side-icon>
<v-toolbar-title>
<router-link to="/" tag="span" style="cursor: pointer">{{ appTitle }}</router-link>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-xs-only">
<v-btn flat v-for="item in menuItems" :key="item.title" :to="item.path">
<v-icon left dark>{{ item.icon }}</v-icon>
{{ item.title }}
</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-content>
<router-view/>
</v-content>
</v-app>
</template>
<script>
import Vue from 'vue';
import Vuetify from 'vuetify';
import router from '#/router';
Vue.use(Vuetify);
export default {
data() {
return {
appTitle: 'MyEvents',
sidebar: false,
drawer: null,
menuItems: [
{ title: 'Home', path: '/home', icon: 'home' },
{ title: 'Sign Up', path: '/signup', icon: 'home' },
{ title: 'Sign In', path: '/signin', icon: 'home' }
]
};
}
};
</script>
<style>
expected page display like below.
But the as per code page display appear below.
Here my side navigation does not appear properly.
Are you using vue-cli for the project?
If that, you have to install the plugin vue-cli-plugin-vuetify via vue ui.
Here the link: https://vuetifyjs.com/en/getting-started/quick-start
Greetings!