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.
Skeleton
We can add placeholder items that we display when data is loading with the q-skeleton
component.
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"
/>
</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 row">
<q-card style="max-width: 300px;">
<q-item>
<q-item-section avatar>
<q-skeleton type="QAvatar"></q-skeleton>
</q-item-section>
<q-item-section>
<q-item-label>
<q-skeleton type="text"></q-skeleton>
</q-item-label>
<q-item-label caption>
<q-skeleton type="text"></q-skeleton>
</q-item-label>
</q-item-section>
</q-item>
<q-skeleton height="200px" square></q-skeleton>
<q-card-actions align="right" class="q-gutter-md">
<q-skeleton type="QBtn"></q-skeleton>
<q-skeleton type="QBtn"></q-skeleton>
</q-card-actions>
</q-card>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
We set the type
prop to set what kind of skeleton we want to show.
QAvatar
shows an avatar placeholder.
QBtn
shows a button placeholder.
text
shows a text placeholder.
Other options for the type
prop include:
QSlider
rect
circle
QBadge
QChip
QToolbar
QCheckbox
QRadio
QToggle
QRange
QInput
We can add animation effects for q-skeleton
components.
We can set it by setting the animation
prop:
<!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 row">
<q-card flat bordered style="width: 250px;">
<q-card-section>
<div class="text-caption">wave</div>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<q-skeleton animation="wave"></q-skeleton>
</q-card-section>
</q-card>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
Other options for the animation
prop include:
pulse
pulse-x
pulse-y
fade
blink
none
We can set the size of the q-skeleton
with the size
, width
and height
props:
<!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-skeleton type="circle" size="100px"></q-skeleton>
<br />
<q-skeleton width="150px"></q-skeleton>
<br />
<q-skeleton height="150px"></q-skeleton>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
We can add a border to the skeletons with the bordered
prop:
<!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-skeleton bordered type="circle"></q-skeleton>
<br />
<q-skeleton bordered></q-skeleton>
<br />
<q-skeleton bordered square></q-skeleton>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
Conclusion
We can add placeholders to display when items are loading with the q-skeleton
component.