I have been trying to put the back to top button in v-dialog using vuetify1.5 and I have used the following inbuilt method of vuetify that is $vuetify.goTo(0) but it seems to be not working any idea how i resolve this issue .
Or any other alternate way to put a back to top button in v-dialog fullscreen using vuetify.
For example :-
<div id="app">
<v-app id="inspire">
<v-row justify="center">
<v-dialog v-model="dialog" fullscreen hide-overlay transition="dialog-bottom-transition">
<template v-slot:activator="{ on, attrs }">
<v-btn
color="primary"
dark
v-bind="attrs"
v-on="on"
>
Open Dialog
</v-btn>
</template>
<v-card>
<v-toolbar dark color="primary">
<v-btn icon dark #click="dialog = false">
<v-icon>mdi-close</v-icon>
</v-btn>
<v-toolbar-title>Settings</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn dark text #click="dialog = false">Save</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-list three-line subheader>
<v-subheader>User Controls</v-subheader>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Content filtering</v-list-item-title>
<v-list-item-subtitle>Set the content filtering level to restrict apps that can be downloaded</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content>
<v-list-item-title>Password</v-list-item-title>
<v-list-item-subtitle>Require password for purchase or use password to restrict purchase</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list three-line subheader>
<v-subheader>General</v-subheader>
<v-list-item>
<v-list-item-action>
<v-checkbox v-model="notifications"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Notifications</v-list-item-title>
<v-list-item-subtitle>Notify me about updates to apps or games that I downloaded</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-action>
<v-checkbox v-model="sound"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Sound</v-list-item-title>
<v-list-item-subtitle>Auto-update apps at any time. Data charges may apply</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-action>
<v-checkbox v-model="widgets"></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>Auto-add widgets</v-list-item-title>
<v-list-item-subtitle>Automatically add home screen widgets</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</v-list>
<v-btn
fab
dark
fixed
bottom
right
color="primary"
#click="$vuetify.goTo(0)"
>
<v-icon>keyboard_arrow_up</v-icon>
</v-btn>
</v-card>
</v-dialog>
</v-row>
</v-app>
</div>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
dialog: false,
notifications: false,
sound: true,
widgets: false,
}
},
})
To achieve it, you can use scrollIntoView() to scroll on the top element in the modal.
Vuetify doesn't work on events inside the browser. It provides component for the building an application.
new Vue({
el: "#app",
methods: {
scrollToTop: function() {
document
.getElementById("container")
.scrollIntoView({ behavior: "smooth" });
}
}
})
#app {
height: 850px;
}
.container {
height: 800px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div class="container" id="container">
This is a long div
</div>
<button #click="scrollToTop()">
scroll Top
</button>
</div>
Related
I would like to put my navigation drawer under the toolbar.
I'm trying to achieve something like this :
I am trying to do something similar but all attempts are unsuccessful, at the moment I have the following:
My code:
<template>
<nav>
<v-snackbar v-model="snackbar" :timeout="4000" top color="success">
<span>Awesome! You added a new project.</span>
<v-btn text flat #click="snackbar = false">Close</v-btn>
</v-snackbar>
<v-toolbar app clipped-left >
<v-toolbar-side-icon></v-toolbar-side-icon>
<v-app-bar-nav-icon #click.stop="drawer = !drawer"></v-app-bar-nav-icon>
<v-toolbar-title class="text-uppercase gr ey--text">
<span class="font-weight-light">estudos</span>
<span>vue</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-menu offset-y>
<template v-slot:activator="{ on, attrs }">
<v-btn text
color="primary"
dark
v-bind="attrs"
v-on="on"
>
<v-icon left>expand_more</v-icon>
<span>Menu</span>
</v-btn>
</template>
<v-list>
<v-list-item v-for="link in links" :key="link.text" router :to="link.route">
<v-list-item-title>{{link.text}}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-btn text color="grey">
<span>Sign Out</span>
<v-icon right>exit_to_app</v-icon>
</v-btn>
</v-toolbar>
<v-navigation-drawer v-model="drawer" app class="indigo white--text">
<v-app-bar-nav-icon #click.stop="drawer = !drawer"></v-app-bar-nav-icon>
<v-layout column align-center>
<v-flex class="mt-5">
<v-avatar size="90">
<img src="/avatar-64.png">
</v-avatar>
<p class="white-text dubheading mt-1">
Estudos Vue
</p>
</v-flex>
<v-flex class="mt-4 mb-3">
<popup #projectAdded="snackbar=true" />
</v-flex>
</v-layout>
<v-list >
<v-divider></v-divider>
<v-list-item
v-for="link in links"
:key="link.text"
router :to="link.route"
>
<v-list-item-action >
<v-icon class="white--text">{{ link.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content class="white--text">
<v-list-item-title>{{ link.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-row>
<v-col
>
<v-img
max-height="76%"
max-width="100%"
src="/imgtest.jpg"
gradient="to top right, rgba(14,12,11,.51), rgba(14,12,11,.71)"
>
<v-img-title class="heading white--text">
Bien saude</v-img-title></v-img>
</v-col>
</v-row>
</nav>
</template>
<script>
import Popup from './Popup'
export default {
components: { Popup },
data() {
return {
drawer:false,
links:[
{icon: 'dashboard', text:'Dashboard', route:'/'},
{icon: 'folder', text:'My Projects', route:'/projects'},
{icon: 'person', text:'Team', route:'/team'},
],
items: [
{ title: 'Click Me' },
{ title: 'Click Me' },
{ title: 'Click Me' },
{ title: 'Click Me 2' },
],
snackbar: true
}
},
}
</script>
I tried adding Block and removing the app, but it didn't solve the problem...
How do I put my drawer under the toolbar?
Add clipped to v-navigation-drawer props like:
<v-navigation-drawer
clipped>
<!-- ... -->
</v-navigation-drawer>
I would suggest following vuetify.js' default markup first.
Then you'll supposed to use clipped property in the <v-navigation-drawer> element like #mamadou-hady-barry already described. (<v-navigation-drawer clipped app>).
Secondly add the 'clipped-left' to the <v-app-bar> element resulting in: <v-app-bar clipped-left app>.
You are currently using <v-toolbar> which does not have a clipped-left property according to their "API".
I've got a vuetify v-menu, with conditionnal item :
<v-menu min-width="225">
<template v-slot:activator="scope">
<v-btn small text color="primary" v-on="scope.on" :loading="actionLoading">
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</template>
<v-list dense>
<v-list-item-group color="primary">
<v-list-item v-if="itemOneCondition()" #click="doSomething()">
<v-list-item-content>
<v-list-item-title>
Item 1
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="itemTwoCondition()" #click="something()">
<v-list-item-content>
<v-list-item-title>
Title 2
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-list-item-group>
</v-menu>
It happens that something every item is not visible (every v-if conditions are false). So the menu hasn't any item.
In this cas, the button is still activ, and a menu is opened with no entry :
Is there a way to disable the button when no item are visible ?
You need a v-if condition for the entire menu like so
<v-menu v-if="menuitems.length > 0" min-width="225"> </v-menu>
When there are no menu items, or the menu items array.length is 0, then the menu panel will not be displayed
Checkout this code snippet, You need to store the menu items in an array for this to work. In the code snippet below, when you replace
items: ["Item1","Item2",] with items: []
Notice that the menu with the black background will not be displayed
var app = new Vue({
el: "#menu",
data () {
return {
items: [
"Item1",
"Item2",
]
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div class="menu" id="menu">
<ul style="background: black; color: yellow" v-if="items.length > 0">
<li v-for="(item, index) in items" :key="index">{{item}}</li>
</ul>
</div>
I used this solution, by adding a isAtLeastOneItemDisplayed() function :
<v-menu v-if="isAtLeastOneItemDisplayed()" min-width="225">
<template v-slot:activator="scope">
<v-btn small text color="primary" v-on="scope.on" :loading="actionLoading">
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</template>
<v-list dense>
<v-list-item-group color="primary">
<v-list-item v-if="itemOneCondition()" #click="doSomething()">
<v-list-item-content>
<v-list-item-title>
Item 1
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="itemTwoCondition()" #click="something()">
<v-list-item-content>
<v-list-item-title>
Title 2
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-list-item-group>
</v-menu>
isAtLeastOneItemDisplayed : function(){
return this.itemOneCondition()
|| this.itemTwoCondition();
}
I'm making a web application which contains a navigation drawer, the intention was that the navigation drawer was open by default, and if the screen size changes to a smaller one it should close, if it is changed back to the big screen size it should reopen, but it's currently not working.
i have tried using the break points($vuetify.breakpoint.lgAndUp) and v-model but it doesn't seems to work.
<template>
<!--Start of template layaout-->
<v-layout wrap row>
<!--End of template layout-->
<v-app-bar color="grey lighten-2" light height="80" app clipped-left>
<v-app-bar-nav-icon x-large #click.stop="draw = !draw"></v-app-bar-nav-icon>
<v-img
src="http://logo-load.com/uploads/posts/2016-02/1455472802_logo.png"
lazy-src="http://logo-load.com/uploads/posts/2016-02/1455472802_logo.png"
aspect-ratio="1"
max-width="60"
max-height="60"
class="appTitle"
#click="pushToken('Home')"
></v-img>
<v-toolbar-title class="text-uppercase">
<span #click="pushToken('Home')"> Tools</span>
</v-toolbar-title>
<!--Spacer to keep buttons to the right side-->
<v-spacer></v-spacer>
<!--Apps menu button-->
<!--Apps menu start-->
<v-menu offset-y max-width="200" min-width="200">
<template v-slot:activator="{ on: menu }">
<v-tooltip bottom>
<template v-slot:activator="{ on: tooltip }">
<v-btn text v-on="{ ...tooltip, ...menu }">
<v-icon large>apps</v-icon>
</v-btn>
</template>
<span>Applications</span>
</v-tooltip>
</template>
<v-list>
<v-list-item v-for="(app, index) in apps" :key="index" class="appDecor">
<v-btn :color="app.color" dark>{{app.title}}</v-btn>
</v-list-item>
</v-list>
</v-menu>
<!--Apps menu end-->
<!--Menu template for list menu-->
</v-app-bar>
<!--Log out Dialog-->
<v-dialog v-model="dialog" max-width="350px" transition="dialog-transition">
<v-card>
<v-card-title>Are you sure you want to exit?</v-card-title>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="info" #click="logOut()">yes</v-btn>
<v-spacer></v-spacer>
<v-btn color="info" #click="dialog = false">no</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
</v-dialog>
<!--Dialog-->
<!--Nav drawer start-->
<v-navigation-drawer
v-model="draw"
color="grey lighten-2"
absolute
:clipped-left="$vuetify.breakpoint.lgAndUp"
>
<v-layout row wrap>
<v-container grid-list-xs>
<v-list dense nav>
<v-list-item v-for="item in items" :key="item.id" link>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<span #click="pushToken(item.link)">{{ item.param }}</span>
</v-list-item-content>
</v-list-item>
</v-list>
</v-container>
</v-layout>
<template v-slot:append>
<v-btn #click="dialog = true" block class="my-5">
<v-icon left>exit_to_app</v-icon>Log out
</v-btn>
</template>
</v-navigation-drawer>
<!--Nav drawer end-->
</v-layout>
</template>
i expected the nav drawer being open by default, closing o smaller screens and reopening if changing the screen size to a bigger one, but the actual result is, the drawer open by default and keeps open if the screen size changes(and also a screen overlay is displayed on small screen),if i close it manually it won't open itself when changing between screen sizes.
If you want to find bugs, you should give the relevant code which controls the nav drawer changes.
Simple solution: v-show and change nav drawer's display
for examle:
`
<template>
<v-app>
<v-content>
<div v-show='is_hide_text' ref='text'>
<p>some text</p>
</div>
<button #click='hide_content'>hide_content</button>
</v-content>
</v-app>
</template>
<script>
import HelloWorld from './components/HelloWorld';
export default {
name: 'App',
data: () => ({
//
}),
computed:{
is_hide_text(){
return this.$vuetify.breakpoint.mdAndUp
}
},
methods:{
hide_text(){
this.$refs['text'].style.display = 'none'
}
}
};
</script>
`
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>
Hi I am learning vuetify and I want to change the background of a navigation drawer that I imported from vuetify default layout template.
The tamplate was found and imported on official vuetify docs.
The problem is I am unable to change the background of the drawer and set it to image
This is the Default layout with drawer
<template>
<v-app
id="inspire"
dark
>
<v-navigation-drawer
v-model="drawer"
fixed
clipped
app
>
<v-list dense>
<v-list-tile v-for="item in items" :key="item.text" #click="">
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
{{ item.text }}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-subheader class="mt-3 grey--text text--darken-1">SUBSCRIPTIONS</v-subheader>
<v-list>
<v-list-tile v-for="item in items2" :key="item.text" avatar #click="">
<v-list-tile-avatar>
<img :src="`https://randomuser.me/api/portraits/men/${item.picture}.jpg`" alt="">
</v-list-tile-avatar>
<v-list-tile-title v-text="item.text"></v-list-tile-title>
</v-list-tile>
</v-list>
<v-list-tile class="mt-3" #click="">
<v-list-tile-action>
<v-icon color="grey darken-1">add_circle_outline</v-icon>
</v-list-tile-action>
<v-list-tile-title class="grey--text text--darken-1">Browse Channels</v-list-tile-title>
</v-list-tile>
<v-list-tile #click="">
<v-list-tile-action>
<v-icon color="grey darken-1">settings</v-icon>
</v-list-tile-action>
<v-list-tile-title class="grey--text text--darken-1">Manage Subscriptions</v-list-tile-title>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar
color="red"
dense
fixed
clipped-left
app
>
<v-toolbar-side-icon #click.stop="drawer = !drawer"></v-toolbar-side-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-toolbar>
<v-content>
<v-container fill-height>
<v-layout justify-center align-center>
<v-flex shrink>
<v-tooltip right>
<template v-slot:activator="{ on }">
<v-btn :href="source" icon large target="_blank" v-on="on">
<v-icon large>code</v-icon>
</v-btn>
</template>
<span>Source</span>
</v-tooltip>
<v-tooltip right>
<template v-slot:activator="{ on }">
<v-btn icon large href="https://codepen.io/johnjleider/pen/YeRKwQ" target="_blank" v-on="on">
<v-icon large>mdi-codepen</v-icon>
</v-btn>
</template>
<span>Codepen</span>
</v-tooltip>
</v-flex>
</v-layout>
</v-container>
</v-content>
</v-app>
</template>
<script>
export default {
data: () => ({
drawer: null,
items: [
{ icon: 'trending_up', text: 'Most Popular' },
{ icon: 'subscriptions', text: 'Subscriptions' },
{ icon: 'history', text: 'History' },
{ icon: 'featured_play_list', text: 'Playlists' },
{ icon: 'watch_later', text: 'Watch Later' }
],
items2: [
{ picture: 28, text: 'Joseph' },
{ picture: 38, text: 'Apple' },
{ picture: 48, text: 'Xbox Ahoy' },
{ picture: 58, text: 'Nokia' },
{ picture: 78, text: 'MKBHD' }
]
}),
props: {
source: String
}
}
</script>
I am expecting apply the background image to drawer, example : https://cdn.vuetifyjs.com/images/backgrounds/bg-2.jpg
I tried to use in my drawer src atribute :
<v-navigation-drawer
v-model="drawer"
fixed
clipped
app
src="https://cdn.vuetifyjs.com/images/backgrounds/bg-2.jpg"
>
But that is not working, also I tried wrapping drawer in Div and accessing the class with scoped css but without any success.
There is a backgrounds ready component for drawers at official vuetify codepen : https://codepen.io/pen/?&editable=true&editors=101
that shows using src atribute.
But for some reason it is not working with this example.
Vuetify v1
Codepen
src property does not exist in v1 Navigation drawer
docs, so probably the way to go is just put v-img with 100% height inside the drawer:
<v-navigation-drawer>
<v-img
src="https://cdn.vuetifyjs.com/images/backgrounds/bg-2.jpg"
height="100%"
>
Vuetify v2
Codepen
In Vuetify v2 Navigation drawer
docs it has src property, so it works like so:
<v-navigation-drawer src="https://cdn.vuetifyjs.com/images/backgrounds/bg-2.jpg">