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.
Toolbar
We can add a toolbar with Quasar’sq-toolbar
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;">
<div class="q-pa-md">
<q-toolbar class="text-primary">
<q-btn flat round dense icon="menu"></q-btn>
<q-toolbar-title>
Toolbar
</q-toolbar-title>
<q-btn flat round dense icon="more_vert"></q-btn>
</q-toolbar>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
targetEl: "#target-img-1"
}
});
</script>
</body>
</html>
to add a q-btn
and q-toolbar-title
into the toolbar.
q-toolbar-title
has the toolbar title.
We can add a q-avatar
in our toolbar:
<!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;">
<div class="q-pa-md">
<q-toolbar class="text-primary">
<q-btn flat round dense icon="menu"></q-btn>
<q-avatar>
<img src="https://cdn.quasar.dev/logo/svg/quasar-logo.svg" />
</q-avatar>
<q-toolbar-title>
Toolbar
</q-toolbar-title>
<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 can also add a dropdown into the q-toolbar
:
<!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;">
<div class="q-pa-md">
<q-toolbar class="bg-primary text-white q-my-md shadow-2">
<q-btn flat round dense icon="menu" class="q-mr-sm"></q-btn>
<q-separator dark vertical inset></q-separator>
<q-btn stretch flat label="Link"></q-btn>
<q-space></q-space>
<q-btn-dropdown stretch flat label="Dropdown">
<q-list>
<q-item-label header>Folders</q-item-label>
<q-item
v-for="n in 3"
:key="`x.${n}`"
clickable
v-close-popup
tabindex="0"
>
<q-item-section avatar>
<q-avatar
icon="folder"
color="secondary"
text-color="white"
>
</q-avatar>
</q-item-section>
<q-item-section>
<q-item-label>Photos</q-item-label>
<q-item-label caption>February 22, 2016</q-item-label>
</q-item-section>
<q-item-section side>
<q-icon name="info"></q-icon>
</q-item-section>
</q-item>
<q-separator inset spaced></q-separator>
<q-item-label header>Files</q-item-label>
<q-item
v-for="n in 3"
:key="`y.${n}`"
clickable
v-close-popup
tabindex="0"
>
<q-item-section avatar>
<q-avatar
icon="assignment"
color="primary"
text-color="white"
>
</q-avatar>
</q-item-section>
<q-item-section>
<q-item-label>Vacation</q-item-label>
<q-item-label caption>February 22, 2016</q-item-label>
</q-item-section>
<q-item-section side>
<q-icon name="info"></q-icon>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<q-separator dark vertical></q-separator>
<q-btn stretch flat label="Link"></q-btn>
</q-toolbar>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {}
});
</script>
</body>
</html>
Conclusion
We can add a toolbar into our Vue app with Quasar’s q-toolbar
component.