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.
Tab Ripple Effect
We can a ripple effect on the tabs.
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-tabs v-model="tab">
<q-tab
:ripple="{ color: 'orange' }"
name="mails"
icon="mail"
label="Mails"
></q-tab>
<q-tab
:ripple="{ color: 'orange' }"
name="alarms"
icon="alarm"
label="Alarms"
></q-tab>
<q-tab
:ripple="{ color: 'orange' }"
name="movies"
icon="movie"
label="Movies"
></q-tab>
</q-tabs>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
tab: undefined
}
});
</script>
</body>
</html>
We set the ripple
prop to an object with the color
property.
Indicator Color
We can change the color when the tab is active with the active-color
prop.
And we can change the color of the bottom indicator when the indicator-color
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;">
<div class="q-pa-md">
<q-tabs
class="bg-primary text-white shadow-2"
v-model="tab"
indicator-color="transparent"
active-color="white"
>
<q-tab name="mails" icon="mail" label="Mails"></q-tab>
<q-tab name="alarms" icon="alarm" label="Alarms"></q-tab>
<q-tab name="movies" icon="movie" label="Movies"></q-tab>
</q-tabs>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
tab: undefined
}
});
</script>
</body>
</html>
Tab Notifications
We can add badges to tabs to show notifications.
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-tabs v-model="tab" class="bg-primary text-white shadow-2">
<q-tab name="mails" icon="mail" label="Mails">
<q-badge color="red" floating>2</q-badge>
</q-tab>
<q-tab name="alarms" icon="alarm" label="Alarms">
<q-badge color="red" floating>10+</q-badge>
</q-tab>
<q-tab alert name="movies" icon="movie" label="Movies" />
</q-tabs>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
tab: undefined
}
});
</script>
</body>
</html>
We add the q-badge
into the default slots of the q-tab
components.
Tab Alignment
We can set the alignment of the tabs with the align
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;">
<div class="q-pa-md">
<q-tabs
v-model="tab"
dense
align="left"
class="bg-primary text-white shadow-2"
:breakpoint="0"
>
<q-tab name="mails" icon="mail"></q-tab>
<q-tab name="alarms" icon="alarm"></q-tab>
</q-tabs>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app",
data: {
tab: undefined
}
});
</script>
</body>
</html>
Now all the tabs are displayed on the left side of the screen.
We can also set it to center
, right
and justify
.
Conclusion
We can add ripple effects, set tab notifications, and set tab alignment with Quasar’s tab component.