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.
Spacer
We can add the q-space
component to add a spacer to fill any space.
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">
<q-toolbar class="bg-primary text-white">
<q-btn flat round dense icon="menu"></q-btn>
<q-space></q-space>
<q-btn flat round dense icon="more_vert"></q-btn>
</q-toolbar>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
We add the q-space
component between the q-btn
s to keep them apart.
The q-btn
s will be displayed at the ends of the toolbar.
Spinners
We can add a spinner by using the q-spinner
component.
For example, 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">
<q-spinner color="primary" size="3em" :thickness="10"> </q-spinner>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
We set the diameter with the size
prop.
And thickness
sets the thickness of the edge of the spinner.
color
sets the color of the edge.
Now we should see the spinner with a thick edge.
Quasar comes with many other spinners. For example, we can show animated squares for the loading indicator by writing:
<!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-spinner-cube color="primary" size="3em" :thickness="10">
</q-spinner-cube>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
Other spinners include:
q-spinner-audio
q-spinner-ball
q-spinner-clock
q-spinner-comment
q-spinner-dots
q-spinner-facebook
q-spinner-gears
q-spinner-grid
q-spinner-hearts
q-spinner-hourglass
q-spinner-infinity
q-spinner-oval
q-spinner-pie
q-spinner-puff
q-spinner-radio
q-spinner-rings
q-spinner-tail
Split Screen
We can split the browser screen with the q-splitter
component.
For example, 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">
<q-splitter v-model="splitterModel" style="height: 400px;">
<template v-slot:before>
<div class="q-pa-md">
<div class="text-h4 q-mb-md">Before</div>
<div v-for="n in 20" :key="n" class="q-my-md">
{{ n }}. Lorem ipsum
</div>
</div>
</template>
<template v-slot:after>
<div class="q-pa-md">
<div class="text-h4 q-mb-md">After</div>
<div v-for="n in 20" :key="n" class="q-my-md">
{{ n }}. Quis praesentium
</div>
</div>
</template>
</q-splitter>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
splitterModel: 50
}
});
</script>
</body>
</html>
to add the component to add 2 side by side panels.
splitterModel
sets the percentage of the screen that the left panel takes up.
It’s bound to v-model
to let us set the size of the left panel.
The before
slot has the content for the left panel.
And the after
slot has the content for the right panel.
Conclusion
We can add spacers, spinners, and split-screen panels into our Vue app with Quasar.