Quasar is a popular Vue UI library for developing good looking Vue apps.
In this article, we’ll take a look at how to create Vue apps with the Quasar UI library.
Loading Indicator
We can add a loading indicator inside a card with the q-inner-loading
component.
To add it, we write:
<!DOCTYPE html>
<html>
<head>
<link
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons"
rel="stylesheet"
type="text/css"
/>
<link
href="https://cdn.jsdelivr.net/npm/quasar@1.12.13/dist/quasar.min.css"
rel="stylesheet"
type="text/css"
/>
</head>
<body class="body--dark">
<script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quasar@1.12.13/dist/quasar.umd.min.js"></script>
<div id="q-app">
<q-layout
view="lHh Lpr lFf"
container
style="height: 100vh;"
class="shadow-2 rounded-borders"
>
<div class="q-pa-md">
<q-card class="bg-grey-3 relative-position card-example">
<q-card-section class="q-pb-none">
<div class="text-h6">Lorem Ipsum</div>
</q-card-section>
<q-card-section>
<transition
appear
enter-active-class="animated fadeIn"
leave-active-class="animated fadeOut"
>
<div v-show="showData">
Lorem ipsum dolor sit amet
</div>
</transition>
</q-card-section>
<q-inner-loading :showing="visible">
<q-spinner-gears size="50px" color="primary" />
</q-inner-loading>
</q-card>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
visible: false,
showData: false
},
methods: {
showTextLoading() {
this.visible = true;
this.showData = false;
setTimeout(() => {
this.visible = false;
this.showData = true;
}, 3000);
}
},
beforeMount() {
this.showTextLoading();
}
});
</script>
</body>
</html>
The showing
prop lets us control when to show the indicator.
Intersection
We can use the q-intersection
component as a scroll container.
For instance, we can write:
<!DOCTYPE html>
<html>
<head>
<link
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons"
rel="stylesheet"
type="text/css"
/>
<link
href="https://cdn.jsdelivr.net/npm/quasar@1.12.13/dist/quasar.min.css"
rel="stylesheet"
type="text/css"
/>
<style>
.example-item {
height: 200px;
width: 200px;
}
</style>
</head>
<body class="body--dark">
<script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quasar@1.12.13/dist/quasar.umd.min.js"></script>
<div id="q-app">
<q-layout
view="lHh Lpr lFf"
container
style="height: 100vh;"
class="shadow-2 rounded-borders"
>
<div class="q-pa-md">
<div class="row justify-center q-gutter-sm">
<q-intersection
v-for="index in 60"
:key="index"
class="example-item"
>
<q-card class="q-ma-sm">
<img src="https://cdn.quasar.dev/img/mountains.jpg" />
<q-card-section>
<div class="text-h6">Card #{{ index }}</div>
</q-card-section>
</q-card>
</q-intersection>
</div>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
We add the q-card
inside to add cards to show items.
We can add the transition
prop to add the transition effects:
<!DOCTYPE html>
<html>
<head>
<link
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons"
rel="stylesheet"
type="text/css"
/>
<link
href="https://cdn.jsdelivr.net/npm/quasar@1.12.13/dist/quasar.min.css"
rel="stylesheet"
type="text/css"
/>
<style>
.example-item {
height: 200px;
width: 200px;
}
</style>
</head>
<body class="body--dark">
<script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quasar@1.12.13/dist/quasar.umd.min.js"></script>
<div id="q-app">
<q-layout
view="lHh Lpr lFf"
container
style="height: 100vh;"
class="shadow-2 rounded-borders"
>
<div class="q-pa-md">
<div class="row justify-center q-gutter-sm">
<q-intersection
transition="scale"
v-for="index in 60"
:key="index"
class="example-item"
>
<q-card class="q-ma-sm">
<img src="https://cdn.quasar.dev/img/mountains.jpg" />
<q-card-section>
<div class="text-h6">Card #{{ index }}</div>
</q-card-section>
</q-card>
</q-intersection>
</div>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
Conclusion
We can add loading indicators and watch intersections with Quasar.