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.
Related
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.
I get reference from here : https://vuetifyjs.com/en/getting-started/quick-start
I run vue create my-app, vue add vuetify and npm run serve
My App.vue like this :
<template>
<v-app>
<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
v-for="link in links"
:key="link"
text
rounded
class="my-2"
:to="'/'+link"
>
{{ link }}
</v-btn>
<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>
<HelloWorld/>
</v-content>
</v-app>
</template>
<script>
import HelloWorld from './components/HelloWorld';
export default {
name: 'App',
components: {
HelloWorld,
},
data: () => ({
links: [
'home',
'about',
'contact',
]
}),
};
</script>
My router.js like this :
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
Vue.use(Router)
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
component: () => import('./views/About.vue')
},
{
path: '/contact',
name: 'contact',
component: () => import('./views/Contact.vue')
}
]
})
My Home.vue like this :
<template>
<HelloWorld />
</template>
<script>
import HelloWorld from '../components/HelloWorld';
export default {
components: {
HelloWorld,
},
};
</script>
My HelloWorld.vue like this :
<template>
<v-container>
<v-layout
text-center
wrap
>
<v-flex xs12>
<v-img
:src="require('../assets/logo.svg')"
class="my-3"
contain
height="200"
></v-img>
</v-flex>
<v-flex mb-4>
<h1 class="display-2 font-weight-bold mb-3">
Welcome to Vuetify ss
</h1>
<p class="subheading font-weight-regular">
For help and collaboration with other Vuetify developers,
<br>please join our online
</p>
</v-flex>
</v-layout>
</v-container>
</template>
<script>
export default {
data: () => ({
}),
};
</script>
My About.vue like this :
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
My Contact.vue like this :
<template>
<div class="contact">
<h1>This is an contact page</h1>
</div>
</template>
I want when content is displayed based on the selected menu. For example when the user selects the about menu, it displays content from the about menu. I try like that. The url changes, but the content does not change. How do I solve this problem?
Update :
I try like this :
<v-btn
v-for="link in links"
:key="link"
text
rounded
class="my-2"
:to="{name: 'about'}">
{{ link }}
</v-btn>
But it's the same
You have no <router-view></router-view> component anywhere in your code. This particular component is responsible for rendering any content in the provided route.
Check for the right example here: https://codesandbox.io/s/qx3orn736q
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>
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>
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!