BlogPlaygroundOne

Data iterators

The v-data-iterator component is used for displaying arbitrary data, and shares a majority of its functionality with the v-data-table component. Features include sorting, searching, pagination, and selection.

Usage

The v-data-iterator allows you to customize exactly how to display your data. In this example we are using a grid with cards.

Item 1
Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ratione debitis quis est labore voluptatibus! Eaque cupiditate minima, at placeat totam, magni doloremque veniam neque porro libero rerum unde voluptatem!

Item 2
Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ratione debitis quis est labore voluptatibus! Eaque cupiditate minima, at placeat totam, magni doloremque veniam neque porro libero rerum unde voluptatem!

Item 3
Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ratione debitis quis est labore voluptatibus! Eaque cupiditate minima, at placeat totam, magni doloremque veniam neque porro libero rerum unde voluptatem!

<v-data-iterator :items="items" :page="page" :items-per-page="3"> <template v-slot:default="{ items }"> <template v-for="(item, i) in items" :key="i" > <v-card v-bind="item.raw"></v-card> <br> </template> </template> <template v-slot:footer="{ pageCount }"> <v-pagination v-model="page" :length="pageCount"></v-pagination> </template> </v-data-iterator>
<script setup> import { ref } from 'vue' const page = ref(1) const items = Array.from({ length: 15 }, (k, v) => ({ title: 'Item ' + v + 1, text: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ratione debitis quis est labore voluptatibus! Eaque cupiditate minima, at placeat totam, magni doloremque veniam neque porro libero rerum unde voluptatem!', })) </script>

API

ComponentDescription
v-data-iteratorPrimary Component
Toggle Inline API

Anatomy

The recommended placement of elements inside of a v-data-iterator are:

  • Place a v-toolbar or similar component above the main content
  • Place content after the header
  • Place a v-pagination below the main content

Element / AreaDescription
1. Header (optional)The header is used to display a title and actions
2. ContainerThe container is the root element of the component
3. Footer (optional)The footer is used to display pagination

Guide

The v-data-iterator component is used for displaying data, and shares a majority of its functionality with the v-data-table component. Features include sorting, searching, pagination, and selection.

The following code snippet is an example of a basic v-data-iterator component:

<v-data-iterator :items="[1, 2, 3, 4, 5]">
  <template v-slot:default="{ items }">
    <v-list-item
      v-for="(item, i) in items"
      :key="i"
      :title="`Item ${i}`"
    ></v-list-item>
  </template>
</v-data-iterator>

Examples

The following are a collection of examples that demonstrate more advanced and real world use of the v-data-iterator component.

Slots

The v-data-iterator component has 4 main slots

Default

The v-data-iterator has internal state for both selection and expansion, just like v-data-table. In this example we use the methods isExpanded and toggleExpand available on the default slot.

Frozen Yogurt

A tangy and creamy dessert made from yogurt and sometimes fruit, Frozen Yogurt is a lighter alternative to ice cream. Perfect for those who crave a sweet treat but want to keep it on the healthier side.

Ice cream sandwich

A classic treat featuring a layer of creamy ice cream sandwiched between two cookies or cake layers. Ideal for those hot summer days when you can't decide between a cookie and ice cream.

Eclair

A small, individual cake topped with frosting and often adorned with sprinkles or other decorations. Great for parties or as a quick indulgence when you need a sugar fix.

Cupcake

A small, individual cake topped with frosting and often adorned with sprinkles or other decorations. Great for parties or as a quick indulgence when you need a sugar fix.

Controllable props

Sorting, filters and pagination can be controlled externally by using the individual props

The Sci-Fi Shooter Experience
Dive into a futuristic world of intense battles and alien encounters.
8 minutes
Epic Adventures in Open Worlds
Embark on a journey through vast, immersive landscapes and quests.
10 minutes
Surviving the Space Station Horror
Navigate a haunted space station in this chilling survival horror game.
9 minutes
Page 1 of 3

Loader props

Loader can be used to change loader on “loading” prop

Ready for more?

Continue your learning with related content selected by the Team or move between pages by using the navigation links below.