When the navigation drawer is closed or open, it creates a big gap on the page based on it's height. How can that be avoided?
In the second image it's clearly visible between the navbar and Create Post component that the drawer takes up room
<template>
<v-app>
<v-navigation-drawer clipped v-model="sideNav">
<v-list>
<v-list-item
v-for="item in items"
:key="item.title"
#click="onClickMenuItem(item.title)"
>
<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.title"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar
dark
fixed
class="default-layout__navbar"
extended
extension-height="3"
>
<v-app-bar-nav-icon
#click.native.stop="sideNav = !sideNav"
class="hidden-sm-and-up"
>
</v-app-bar-nav-icon>
<v-toolbar-title>
<router-link to="/" tag="span" style="cursor: pointer">
Blog
</router-link>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-xs-only">
<v-btn
v-for="item in items"
:key="item.title"
#click="onClickMenuItem(item.title)"
>
<v-icon left dark>{{ item.icon }}</v-icon>
{{ item.title }}
</v-btn>
</v-toolbar-items>
<v-spacer></v-spacer>
<!-- <span class="nav-user" v-if="loggedInUser.token">{{
loggedInUser.username
}}</span> -->
</v-app-bar>
<v-content class="default-layout__main-content">
<transition name="fade" mode="out-in">
<router-view />
</transition>
</v-content>
</v-app>
</template>
If I understand the question, you're looking for a layout like this. Notice how the app prop is used in both the v-navigation-drawer and app-bar...
<v-app>
<v-navigation-drawer v-model="sideNav" app>
<v-list>
<v-list-item v-for="item in items" :key="item.title" #click="onClickMenuItem(item.title)">
<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.title"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar dark fixed app class="default-layout__navbar" extended extension-height="3">
<v-app-bar-nav-icon #click.native.stop="sideNav = !sideNav" class="hidden-sm-and-up">
</v-app-bar-nav-icon>
<v-toolbar-title>
<router-link to="/" tag="span" style="cursor: pointer"> Blog </router-link>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items class="hidden-xs-only">
<v-btn v-for="item in items" :key="item.title" #click="onClickMenuItem(item.title)">
<v-icon left dark>{{ item.icon }}</v-icon>
{{ item.title }}
</v-btn>
</v-toolbar-items>
<v-spacer></v-spacer>
<span class="nav-user"> username </span>
</v-app-bar>
<v-content class="default-layout__main-content">
<transition name="fade" mode="out-in">
<router-view />
</transition>
</v-content>
</v-app>
Demo: https://codeply.com/p/KNNSlNEmzM
Related
I have the following 2-level vuetify list . However, when I tried clicking on a child of the subgroup, the subgroup just collapsed like in the second half of this video.
I notice that when clicking on the child item, the sub list (Stock Statistics)'s isActive property is set to false.
How do I fix so that the subgroup remain open when I click on its child? Thanks in advance!
<template>
<v-list nav expand>
<template v-for="({ label, icon, group, subItems }, index) in items">
<v-list-group
v-if="subItems && subItems.length"
:key="index"
:group="group"
class="v-list--dense"
color="default"
append-icon="mdi-menu-down"
active-class="v-list-group--active"
>
<template #activator>
<v-list-item-icon class="mr-1">
<v-icon color="grey" v-text="icon"></v-icon>
</v-list-item-icon>
<v-list-item-content class="overflow-visible">
<v-list-item-title
class="subtitle-2"
v-text="$t(label)"
></v-list-item-title>
</v-list-item-content>
</template>
<template v-for="(child, idx) in subItems">
<v-tooltip v-if="!child.subChildItems" :key="idx" right>
<template #activator="{ on, attrs }">
<v-list-item
nuxt
:to="{ name: child.routeName }"
v-bind="attrs"
v-on="on"
>
<v-list-item-icon class="ml-4 mr-0">
<v-icon >mdi-circle-small</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title
v-text="$t(child.label)"
></v-list-item-title>
</v-list-item-content>
</v-list-item>
</template>
<span>{{ $t(child.label) }}</span>
</v-tooltip>
<v-list-group
v-else
:key="idx"
:group="child.subGroup"
sub-group
class="v-list--dense"
color="default"
prepend-icon="mdi-circle-small"
active-class="v-list-group--active"
>
<template #activator>
<v-list-item-content class="overflow-visible" style="margin-left: -16px;">
<v-list-item-title
class="subtitle-3"
v-text="$t(child.label)"
></v-list-item-title>
</v-list-item-content>
<v-list-item-icon class="ml-0 mr-0">
<v-icon>mdi-menu-down</v-icon>
</v-list-item-icon>
</template>
<template
v-for="(
{ label, routeName }, idxChild
) in child.subChildItems"
>
<v-tooltip :key="idxChild" right>
<template #activator="{ on, attrs }">
<v-list-item
nuxt
subheader
:to="{ name: routeName }"
v-bind="attrs"
v-on="on"
>
<v-list-item-icon class="ml-4 mr-0">
-
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title
v-text="$t(label)"
></v-list-item-title>
</v-list-item-content>
</v-list-item>
</template>
<span>{{ $t(label) }}</span>
</v-tooltip>
</template>
</v-list-group>
</template>
</v-list-group>
</template>
</v-list>
</template>
I want to set navigation drawer alone with toolbar and toggle drawer from toolbar.
Code:
<v-navigation-drawer absolute temporary left v-model="drawer">
<v-list-item-title class="text-h6"> </v-list-item-title>
<v-list nav dense>
<div v-for="(link, i) in links" :key="i">
<v-list-item v-if="!link.subLinks" :to="link.to" class="v-list-item">
<v-list-item-icon>
<v-icon>{{ link.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-title v-text="link.text" class="subtitle-2" />
</v-list-item>
<v-list-group
v-else
:key="link.text"
no-action
:prepend-icon="link.icon"
:value="false"
>
<template v-slot:activator>
<v-list-item-title>{{ link.text }}</v-list-item-title>
</template>
<v-list-item
v-for="sublink in link.subLinks"
:to="sublink.to"
:key="sublink.text"
>
<v-list-item-icon>
<v-icon>{{ sublink.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-title class="subtitle-2">{{ sublink.text }}</v-list-item-title>
</v-list-item>
</v-list-group>
</div>
</v-list>
</v-navigation-drawer>
<v-toolbar color="primary" right #click.stop="drawer = !drawer">
<v-app-bar-nav-icon #click.stop="drawer = !drawer"></v-app-bar-nav-icon>
<v-spacer></v-spacer>
</v-toolbar>
As you can see I have set both navigation-drawer and toolbar.
Currently:
Expected:
Replace the v-toolbar with v-app-bar
Add app clipped-left props to v-app-bar
Remove absolute temporary props from the drawer
Add app clipped fixed props to the drawer
I've been trying to implement a v-menu on a v-btn that as v-for. It works fine without v-for. I'm retrieving the category name using axios. So dont mind that. I just want the v-menu to work like that.
<div class="text-center">
<v-menu
:close-on-content-click="false"
:nudge-width="200"
offset-x
>
<template v-slot:activator="{ on, attrs }">
<v-btn
color="indigo"
dark
v-bind="attrs"
v-on="on"
:value="categoryid"
v-for="(categoryItem, i) in categoryList" :key="i"
#click="subcat(categoryItem._id)"
>
{{ categoryItem.cname }}
</v-btn>
</template>
<v-card>
<v-list>
<v-list-item>
<v-list-item-avatar>
<img
src="https://cdn.vuetifyjs.com/images/john.jpg"
alt="John"
/>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>John Leider</v-list-item-title>
<v-list-item-subtitle
>Founder of Vuetify</v-list-item-subtitle
>
</v-list-item-content>
<v-list-item-action>
<v-btn icon>
<v-icon>mdi-heart</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</v-list>
<v-divider></v-divider>
</v-card>
</v-menu>
</div>
I have some problems with my Vue.js Project.
Parent Component:
<v-menu>
<template v-slot:activator="{ on }">
<more-actions :ref="'moreActions' v-on="on" />
</template>
<v-list>
<v-list-item #click="handleClick()">
<v-list-item-title>
Sample
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
MoreActions Component
<template>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn icon v-on="on" #click="$emit('click', $event)">
<v-icon small>
more_vert
</v-icon>
</v-btn>
</template>
<span>More Actions</span>
</v-tooltip>
</template>
This code is running well(under Vuetify v2.1.9), but doesn't run in Vuetify v2.1.15
(The menu is opend the top left corner.)
How can I fix this?
Here is running code in v2.1.15
<template>
<div class="text-center">
<v-menu>
<template v-slot:activator="{ on: menu }">
<v-tooltip bottom>
<template v-slot:activator="{ on: tooltip }">
<v-btn icon v-on="{ ...tooltip, ...menu }" #click="$emit('click', $event)">
<v-icon small>
more_vert
</v-icon>
<v-btn>
</template>
<span>Im A ToolTip</span>
</v-tooltip>
</template>
<v-list>
<v-list-item #click="handleClick()">
<v-list-item-title>
Sample
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</div>
</template>
Please help me.
move this part to the parent component.
and using <slot /> instead of this part in Child Component.
<v-list>
<v-list-item #click="handleClick()">
<v-list-item-title>
Sample
</v-list-item-title>
</v-list-item>
</v-list>
With Vuetify I would like to display two v-navigation-drawers next to each other and be able to hide the right one with a button within the left one. My current code (see below) displays the right drawer over the left one, but I want it to display right drawer next to the left one (see screens below).
I tried to find something useful in the official documentation and went through a few different sample templates but nothing was helpful in my case.
I was able to come up with the following code:
<template>
<v-app dark>
<v-navigation-drawer v-model="leftMenu" app clipped>
<v-container ma-0 pa-0>
<v-toolbar flat>
<span>Some helper toolbar</span>
</v-toolbar>
</v-container>
<v-container pa-1 mt-1>
<v-layout row wrap>
<v-list>
<v-list-tile>
<v-list-tile-action>
<span><a #click.stop="toggleRightMenu"><v-icon>android</v-icon> Task Menu</a></span>
</v-list-tile-action>
</v-list-tile>
<v-list-tile>
<v-list-tile-action>
<span><v-icon>android</v-icon> Menu Element #1</span>
</v-list-tile-action>
</v-list-tile>
</v-list>
</v-layout>
</v-container>
</v-navigation-drawer>
<v-navigation-drawer v-model="rightMenu" app clipped>
<v-container>
<v-layout>
<v-list>
<v-list-tile>
<v-list-tile-action>
<span><v-icon>android</v-icon> Testing...</span>
</v-list-tile-action>
</v-list-tile>
</v-list>
</v-layout>
</v-container>
</v-navigation-drawer>
<v-toolbar app clipped-left>
<v-toolbar-side-icon #click="leftMenu = !leftMenu"></v-toolbar-side-icon>
<v-toolbar-title class="headline">
<span>Testing...</span>
</v-toolbar-title>
<v-spacer></v-spacer>
</v-toolbar>
<v-content>
<router-view/>
</v-content>
<v-footer app>
<span>Footer</span>
</v-footer>
</v-app>
</template>
<script>
export default {
name: 'App',
data() {
return {
leftMenu: true,
rightMenu: false
}
},
methods: {
toggleRightMenu() {
this.rightMenu = !this.rightMenu;
}
}
}
</script>
Currently I have the following: https://i.ibb.co/txdN0X8/current-drawer.png
I am looking for something like that: https://i.ibb.co/b514yyC/target-drawer.png
The trick is to have a v-layout that fills the height and contains both of the navigation drawers.
One more thing that you need to make sure to apply is to have a z-index on both navigation drawers. Otherwise, when you toggle the right nav it will go at the top of the left nav. And when you want to toggle the left nav you actually have to toggle both.
I have created a Codepen using your data example.
<v-toolbar flat>
<v-toolbar-side-icon #click="toggleLeftMenu"></v-toolbar-side-icon>
<v-toolbar-title class="headline">
<span>Testing...</span>
</v-toolbar-title>
<v-spacer></v-spacer>
</v-toolbar>
<v-layout fill-height>
<v-navigation-drawer
style="z-index: 2"
dark
clipped
stateless
v-model="leftMenu"
>
<v-container ma-0 pa-0>
<v-toolbar flat>
<span>Some helper toolbar</span>
</v-toolbar>
</v-container>
<v-list>
<v-list-tile>
<v-list-tile-action>
<v-icon #click="rightMenu = !rightMenu">android</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Task Menu</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile>
<v-list-tile-action>
<v-icon>android</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Menu Element #1</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-navigation-drawer
dark
style="z-index: 1"
v-model="rightMenu"
class="pb-0"
stateless
>
<v-list>
<v-list-tile>
<v-list-tile-action>
<v-icon>android</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Testing right nav</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
</v-layout>
Hope it helps :)
You could try achieve by having 2 navigation drawers.
The second one's margin-left should be equivalent to the first drawer.
Please take a look at this code pen. Hope this helps.
https://codepen.io/Jubels/pen/xeazYY?&editable=true&editors=101
<div id="app">
<v-app id="inspire">
<v-layout
wrap
style="height: 200px;"
>
<v-container>
<v-layout justify-center>
<v-btn
color="pink"
dark
#click.stop="drawer = !drawer"
>
Toggle Drawer 1
</v-btn>
<v-btn
color="pink"
dark
#click.stop="drawer2 = !drawer2"
>
Toggle Drawer 2
</v-btn>
</v-layout>
</v-container>
<v-navigation-drawer
v-model="drawer"
:mini-variant="mini"
absolute
dark
>
<v-list class="pa-1">
<v-list-tile v-if="mini" #click.stop="mini = !mini">
<v-list-tile-action>
<v-icon>chevron_right</v-icon>
</v-list-tile-action>
</v-list-tile>
<v-list-tile avatar tag="div">
<v-list-tile-avatar>
<img src="https://randomuser.me/api/portraits/men/85.jpg">
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>John Leider</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-btn icon #click.stop="mini = !mini">
<v-icon>chevron_left</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-list class="pt-0" dense>
<v-divider light></v-divider>
<v-list-tile
v-for="item in items"
:key="item.title"
#click=""
>
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>{{ item.title }}</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-navigation-drawer :style="`margin-left: ${drawer ? '300px' : '0'}`"
v-model="drawer2"
:mini-variant="mini"
absolute
dark
>
<v-list class="pa-1">
<v-list-tile v-if="mini" #click.stop="mini = !mini">
<v-list-tile-action>
<v-icon>chevron_right</v-icon>
</v-list-tile-action>
</v-list-tile>
<v-list-tile avatar tag="div">
<v-list-tile-avatar>
<img src="https://randomuser.me/api/portraits/men/85.jpg">
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>John Leider</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-btn icon #click.stop="mini = !mini">
<v-icon>chevron_left</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-list class="pt-0" dense>
<v-divider light></v-divider>
<v-list-tile
v-for="item in items"
:key="item.title"
#click=""
>
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>{{ item.title }}</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
</v-layout>
</v-app>
</div>
I made it like bitbucket design, one is fixed (mini-variant) and the other one is a drawer
https://codepen.io/admica/pen/PoozMNw?editors=1010
<div id="app">
<v-app id="inspire">
<v-navigation-drawer
mini-variant
mini-variant-width="56"
app
clipped
>
<v-list dense>
<v-list-item
v-for="item in items"
:key="item.text"
#click=""
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
{{ item.text }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-subheader class="mt-3 grey--text text--darken-1">SUBSCRIPTIONS</v-subheader>
<v-list>
<v-list-item
v-for="item in items2"
:key="item.text"
#click=""
>
<v-list-item-avatar>
<img
:src="`https://randomuser.me/api/portraits/men/${item.picture}.jpg`"
alt=""
>
</v-list-item-avatar>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item>
</v-list>
<v-list-item
class="mt-3"
#click=""
>
<v-list-item-action>
<v-icon color="grey darken-1">add_circle_outline</v-icon>
</v-list-item-action>
<v-list-item-title class="grey--text text--darken-1">Browse Channels</v-list-item-title>
</v-list-item>
<v-list-item #click="">
<v-list-item-action>
<v-icon color="grey darken-1">settings</v-icon>
</v-list-item-action>
<v-list-item-title class="grey--text text--darken-1">Manage Subscriptions</v-list-item-title>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar
app
color="red"
dense
>
<v-app-bar-nav-icon #click.stop="drawer = !drawer"></v-app-bar-nav-icon>
<v-icon class="mx-3">fab fa-youtube</v-icon>
<v-toolbar-title class="mr-5 align-center">
<span class="title">Youtube</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-layout
row
align-center
style="max-width: 650px"
>
<v-text-field
:append-icon-cb="() => {}"
placeholder="Search..."
single-line
append-icon="search"
color="white"
hide-details
></v-text-field>
</v-layout>
</v-app-bar>
<v-content>
<v-container fluid fill-height>
<v-layout
align-center
style="position:relative"
>
<v-navigation-drawer
v-model="drawer"
v-if="drawer"
>
<v-list-item>
<v-list-item-avatar>
<v-img src="https://randomuser.me/api/portraits/men/78.jpg"></v-img>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>John Leider</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-divider></v-divider>
<v-list dense>
<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>
</v-navigation-drawer>
ahmed ali
</v-layout>
</v-container>
</v-content>
</v-app>
</div>