Vuetify is a popular UI framework for Vue apps.
In this article, we’ll look at how to work with the Vuetify framework.
Timelines
We can use the v-timeline
component to display data chronologically.
For example, we can write:
<template>
<v-timeline :dense="$vuetify.breakpoint.smAndDown">
<v-timeline-item color="purple lighten-2" fill-dot right>
<v-card>
<v-card-title class="purple lighten-2">
<v-icon dark size="42" class="mr-4">mdi-magnify</v-icon>
<h2 class="display-1 white--text font-weight-light">Title 1</h2>
</v-card-title>
<v-container>
<v-row>
<v-col cols="12" md="10">Lorem ipsum dolor sit amet, no nam oblique veritus.</v-col>
<v-col class="hidden-sm-and-down text-right" md="2">
<v-icon size="64">mdi-calendar-text</v-icon>
</v-col>
</v-row>
</v-container>
</v-card>
</v-timeline-item>
<v-timeline-item color="amber lighten-1" fill-dot left small>
<v-card>
<v-card-title class="amber lighten-1 justify-end">
<h2 class="display-1 mr-4 white--text font-weight-light">Title 2</h2>
<v-icon dark size="42">mdi-home-outline</v-icon>
</v-card-title>
<v-container>
<v-row>
<v-col cols="12" md="8">Lorem ipsum dolor sit amet.</v-col>
</v-row>
</v-container>
</v-card>
</v-timeline-item>
<v-timeline-item color="cyan lighten-1" fill-dot right>
<v-card>
<v-card-title class="cyan lighten-1">
<v-icon class="mr-4" dark size="42">mdi-email-outline</v-icon>
<h2 class="display-1 white--text font-weight-light">Title 3</h2>
</v-card-title>
<v-container>
<v-row>
<v-col v-for="n in 3" :key="n" cols="12" md="4">Lorem ipsum dolor sit amet.</v-col>
</v-row>
</v-container>
</v-card>
</v-timeline-item>
</v-timeline>
</template>
<script>
export default {
name: "HelloWorld",
};
</script>
We have the v-timeline
component with the v-timeline-item
components inside it.
The v-timeline-item
has the cards to display the content we want.
The v-card-title
has the title.
And v-container
has the content.
The right
prop makes the entry display to the right of the line.
The left
prop makes the entry display to the left of the line.
fill-dot
makes the dot filled.
Icon Dots
We can change the dots on the timeline to be icons instead.
For example, we can write:
<template>
<v-timeline align-top :dense="$vuetify.breakpoint.smAndDown">
<v-timeline-item
v-for="(item, i) in items"
:key="i"
:color="item.color"
:icon="item.icon"
fill-dot
>
<v-card :color="item.color" dark>
<v-card-title class="title">Lorem Ipsum Dolor</v-card-title>
<v-card-text class="white text--primary">
<p>Lorem ipsum dolor sit amet.</p>
<v-btn :color="item.color" class="mx-0" outlined>Button</v-btn>
</v-card-text>
</v-card>
</v-timeline-item>
</v-timeline>
</template>
<script>
export default {
name: "HelloWorld",
data: () => ({
items: [
{
color: "red lighten-2",
icon: "mdi-star",
},
{
color: "purple darken-1",
icon: "mdi-book-variant",
},
{
color: "green lighten-1",
icon: "mdi-airballoon",
},
],
}),
};
</script>
We render the items with the v-timeline-item
by setting the icon
prop to set the icon name to display.
The color
prop also changes the color.
Conclusion
We can add a timeline to display items in chronological order