Skip to content

ListView, GridView & ScrollView

ListView

A scrollable list of widgets arranged linearly.

Vertical ListView
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
vue
<template>
  <SizedBox :width="300" :height="200">
    <ListView :padding="EdgeInsets.all(10)">
      <Container
        v-for="i in 10"
        :key="i"
        :width="80"
        :height="80"
        :color="i % 2 === 0 ? 'orange' : 'coral'"
        :margin="EdgeInsets.only({ right: 10 })"
        alignment="center"
      >
        <Text :data="`Item ${i}`" :style="TextStyle({ color: 'white' })" />
      </Container>
    </ListView>
  </SizedBox>
</template>

<script setup lang="ts">
import { Container, ListView, Text, SizedBox, TextStyle, EdgeInsets } from "fluekit";
</script>
Horizontal ListView
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
vue
<template>
  <SizedBox width="500" height="100">
    <ListView scrollDirection="horizontal" :padding="EdgeInsets.all(10)">
      <Container
        v-for="i in 10"
        :key="i"
        :width="80"
        :height="80"
        :color="i % 2 === 0 ? 'orange' : 'coral'"
        :margin="EdgeInsets.only({ right: 10 })"
        alignment="center"
      >
        <Text :data="`Item ${i}`" :style="TextStyle({ color: 'white' })" />
      </Container>
    </ListView>
  </SizedBox>
</template>

<script setup lang="ts">
import { Container, ListView, Text, SizedBox, TextStyle, EdgeInsets } from "fluekit";
</script>

GridView

A scrollable, 2D array of widgets.

Grid 1
Grid 2
Grid 3
Grid 4
Grid 5
Grid 6
Grid 7
Grid 8
Grid 9
vue
<template>
  <SizedBox :height="200">
    <GridView
      :crossAxisCount="3"
      :mainAxisSpacing="10"
      :crossAxisSpacing="10"
      :padding="EdgeInsets.all(10)"
    >
      <Container v-for="i in 9" :key="i" :height="80" color="purple" alignment="center">
        <Text :data="`Grid ${i}`" :style="TextStyle({ color: 'white' })" />
      </Container>
    </GridView>
  </SizedBox>
</template>

<script setup lang="ts">
import { Container, GridView, Text, SizedBox, TextStyle, EdgeInsets } from "fluekit";
</script>

ScrollView

A box in which a single widget can be scrolled.

  • ScrollView with Sticky Header
Header
Sticky Header
Scroll Item 1
Scroll Item 2
Scroll Item 3
Scroll Item 4
Scroll Item 5
Scroll Item 6
Scroll Item 7
Scroll Item 8
Scroll Item 9
Scroll Item 10
End of List
vue
<template>
  <Container
    :height="300"
    :width="300"
    :decoration="BoxDecoration({ border: Border.all({ color: 'black', width: 1 }) })"
  >
    <ScrollView :padding="EdgeInsets.all(0)">
      <Column>
        <Container :height="50" color="lightgrey" alignment="center">
          <Text data="Header" />
        </Container>

        <Sticky :top="0" :zIndex="100">
          <Container :height="40" color="teal" alignment="center" :width="300">
            <Text
              data="Sticky Header"
              :style="TextStyle({ color: 'white', fontWeight: FontWeight.bold })"
            />
          </Container>
        </Sticky>

        <Container
          v-for="i in 10"
          :key="i"
          :height="60"
          color="lightblue"
          :margin="EdgeInsets.only({ top: 10, right: 10, bottom: 10, left: 10 })"
          alignment="center"
        >
          <Text :data="`Scroll Item ${i}`" />
        </Container>
        <Text data="End of List" :textAlign="TextAlign.center" />
      </Column>
    </ScrollView>
  </Container>
</template>

<script setup lang="ts">
import {
  Column,
  Container,
  ScrollView,
  Sticky,
  Text,
  TextAlign,
  BoxDecoration,
  Border,
  EdgeInsets,
  TextStyle,
  FontWeight,
} from "fluekit";
</script>

API

ListView

Props

NameTypeDefaultDescription
scrollDirection'vertical' | 'horizontal''vertical'The direction to scroll.
paddingEdgeInsets-The amount of space by which to inset the child.
physics'bouncing' | 'clamping' | 'never' | 'always''bouncing'How the scroll view should respond to user input.
shrinkWrapbooleanfalseWhether the extent of the scroll view in the scrollDirection should be determined by the contents being viewed.
itemCountnumber-The number of items in the list.
itemExtentnumber | string-If non-null, forces the children to have the given extent in the scroll direction.
separatorbooleanfalseWhether to show a separator between items.
clipBehavior'none' | 'hardEdge' | 'antiAlias''hardEdge'The content will be clipped (or not) according to this option.

Slots

NameDescription
defaultThe content when itemCount is not provided.
itemThe builder for items when itemCount is provided. Props: { index: number }.
separatorThe builder for separators. Props: { index: number }.

GridView

Props

NameTypeDefaultDescription
scrollDirection'vertical' | 'horizontal''vertical'The direction to scroll.
paddingEdgeInsets-The amount of space by which to inset the child.
physics'bouncing' | 'clamping' | 'never' | 'always''bouncing'How the scroll view should respond to user input.
shrinkWrapbooleanfalseWhether the extent of the scroll view in the scrollDirection should be determined by the contents being viewed.
clipBehavior'none' | 'hardEdge' | 'antiAlias''hardEdge'The content will be clipped (or not) according to this option.
crossAxisCountnumber2The number of children in the cross axis.
mainAxisSpacingnumber | string0The number of logical pixels between each child along the main axis.
crossAxisSpacingnumber | string0The number of logical pixels between each child along the cross axis.
childAspectRationumber1.0The ratio of the cross-axis to the main-axis extent of each child.
itemCountnumber-The number of items in the grid.

Slots

NameDescription
defaultThe content when itemCount is not provided.
itemThe builder for items when itemCount is provided. Props: { index: number }.

ScrollView

Props

NameTypeDefaultDescription
scrollDirection'vertical' | 'horizontal''vertical'The direction to scroll.
paddingEdgeInsets-The amount of space by which to inset the child.
physics'bouncing' | 'clamping' | 'never' | 'always''bouncing'How the scroll view should respond to user input.
clipBehavior'none' | 'hardEdge' | 'antiAlias''hardEdge'The content will be clipped (or not) according to this option.
reversebooleanfalseWhether the scroll view scrolls in the reading direction.

Slots

NameDescription
defaultThe child widget.

Events

NameDescription
scrollEmitted when scrolling. Payload: { scrollTop, scrollLeft, scrollHeight, scrollWidth }.
scrollStartEmitted when scrolling starts.
scrollEndEmitted when scrolling ends.

Exposes

NameDescription
scrollToFunction to scroll to a specific position.
scrollRefThe ref of the scroll container.