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.
Lists
Quasar comes with a list component that we can use in a Vue app.
We can add a list with the q-list
component:
<!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">
<q-list bordered separator>
<q-item clickable v-ripple>
<q-item-section>Single line item</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
<q-item-label>Orange</q-item-label>
<q-item-label caption>Caption</q-item-label>
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
<q-item-label overline>Apple</q-item-label>
<q-item-label>Item with caption</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app"
});
</script>
</body>
</html>
The bordered
prop adds a border around the list.
separator
adds a separator between the items.
q-item
lets us add items into the list.
clickable
makes the item clickable.
v-ripple
adds a ripple effect when we click on the item.
q-item-label
is a container for the text in the item.
We can also add a list on a dark background with a few classes and the dark
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"
/>
<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 bg-grey-10 text-white">
<q-list dark bordered separator>
<q-item clickable v-ripple>
<q-item-section>Single line item</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
<q-item-label>Orange</q-item-label>
<q-item-label caption>Caption</q-item-label>
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
<q-item-label overline>Apple</q-item-label>
<q-item-label>Item with caption</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app"
});
</script>
</body>
</html>
bg-grey-10
makes the background dark. text-white
makes the text white.
We can make a dense list with the dense
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"
/>
<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">
<q-list dense bordered padding class="rounded-borders">
<q-item clickable v-ripple>
<q-item-section>
Apple
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
Orange
</q-item-section>
</q-item>
<q-item clickable v-ripple>
<q-item-section>
Grape
</q-item-section>
</q-item>
</q-list>
</div>
</q-layout>
</div>
<script>
new Vue({
el: "#q-app"
});
</script>
</body>
</html>
Conclusion
We can add lists into our Vue with the Quasar library.