Vuetify is a popular UI framework for Vue apps.
In this article, we’ll look at how to work with the Vuetify framework.
Shaped Lists
We can change the shape of the list item.
For example, we can write:
<template>
<v-row>
<v-col cols="12">
<v-card class="mx-auto" max-width="300" tile>
<v-list shaped>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
item: 1,
items: [
{ text: "Clock", icon: "mdi-clock" },
{ text: "Account", icon: "mdi-account" },
{ text: "Flag", icon: "mdi-flag" },
],
}),
};
</script>
The shaped
prop makes the list item displayed with rounded corners on the right side.
Dense Items
We can add the dense
prop to make the items denser:
<template>
<v-row>
<v-col cols="12">
<v-card class="mx-auto" max-width="300" tile>
<v-list dense >
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
item: 1,
items: [
{ text: "Clock", icon: "mdi-clock" },
{ text: "Account", icon: "mdi-account" },
{ text: "Flag", icon: "mdi-flag" },
],
}),
};
</script>
Flat
The flat
prop makes the v-list
items flat:
<template>
<v-row>
<v-col cols="12">
<v-card class="mx-auto" max-width="300" tile>
<v-list flat>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
item: 1,
items: [
{ text: "Clock", icon: "mdi-clock" },
{ text: "Account", icon: "mdi-account" },
{ text: "Flag", icon: "mdi-flag" },
],
}),
};
</script>
Rounded
We can make the list items have rounded corners on all sides with the rounded
prop:
<template>
<v-row>
<v-col cols="12">
<v-card class="mx-auto" max-width="300" tile>
<v-list rounded>
<v-subheader>REPORTS</v-subheader>
<v-list-item-group v-model="item" color="primary">
<v-list-item v-for="(item, i) in items" :key="i">
<v-list-item-icon>
<v-icon v-text="item.icon"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title v-text="item.text"></v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-item-group>
</v-list>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
item: 1,
items: [
{ text: "Clock", icon: "mdi-clock" },
{ text: "Account", icon: "mdi-account" },
{ text: "Flag", icon: "mdi-flag" },
],
}),
};
</script>
Conclusion
We can add lists with various appearances with Vuetify.