List
Scrolling list with bottom-loading: the bottom-hit detection and state machine (idle → loading → finished / error) all consume @lh-ui/share/core/list; the scroll container is detected automatically (the nearest scrollable ancestor, otherwise window), throttled to one check per frame via rAF. The loading indicator reuses the spinner component.
Basic Usage
Basic usage (bottom loading + no more items)
0 items loaded; scrolling to the bottom triggers load (8 per page, 20 in total)
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhList } from '@lh-ui/vue3'
const items = ref<number[]>([])
const loading = ref(false)
const finished = ref(false)
const error = ref(false)
function onLoad() {
loading.value = true
setTimeout(() => {
for (let i = 0; i < 8; i += 1) {
items.value.push(items.value.length + 1)
}
loading.value = false
if (items.value.length >= 20) finished.value = true
}, 600)
}
</script>
<template>
<div class="list-demo-scroll">
<LhList v-model:error="error" :loading="loading" :finished="finished" @load="onLoad">
<div v-for="item in items" :key="item" class="list-demo-item">Order {{ item }}</div>
</LhList>
</div>
</template>vue
<script>
import { LhList } from '@lh-ui/vue3'
export default {
components: { LhList },
data() {
return { items: [], loading: false, finished: false, error: false }
},
methods: {
onLoad() {
this.loading = true
setTimeout(() => {
for (let i = 0; i < 8; i += 1) this.items.push(this.items.length + 1)
this.loading = false
if (this.items.length >= 20) this.finished = true
}, 600)
},
},
}
</script>
<template>
<div class="list-demo-scroll">
<LhList v-model:error="error" :loading="loading" :finished="finished" @load="onLoad">
<div v-for="item in items" :key="item" class="list-demo-item">Order {{ item }}</div>
</LhList>
</div>
</template>Error and empty states
Load failure (tap to retry) and empty-state text
The first bottom-hit simulates a failure (tap "Retry" to recover); when the data is empty, emptyText is shown
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhList } from '@lh-ui/vue3'
const failItems = ref<number[]>([])
const failError = ref(false)
const failFinished = ref(false)
const attempts = ref(0)
function onFailLoad() {
attempts.value += 1
if (attempts.value === 1) {
failError.value = true
return
}
failFinished.value = true
}
</script>
<template>
<div class="list-demo-scroll">
<LhList :error="failError" :finished="failFinished" empty-text="No orders yet" @update:error="failError = $event" @load="onFailLoad">
<div v-for="item in failItems" :key="item" class="list-demo-item">Order {{ item }}</div>
</LhList>
</div>
</template>vue
<script>
import { LhList } from '@lh-ui/vue3'
export default {
components: { LhList },
data() {
return { failItems: [], failError: false, failFinished: false, attempts: 0 }
},
methods: {
onFailLoad() {
this.attempts += 1
if (this.attempts === 1) {
this.failError = true
return
}
this.failFinished = true
},
},
}
</script>
<template>
<div class="list-demo-scroll">
<LhList :error="failError" :finished="failFinished" empty-text="No orders yet" @update:error="failError = $event" @load="onFailLoad">
<div v-for="item in failItems" :key="item" class="list-demo-item">Order {{ item }}</div>
</LhList>
</div>
</template>List API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
| loading | Loading (set to true before pulling data, false after completion) | boolean | false |
| finished | No more items (renders the language-pack text or the finished slot at the bottom) | boolean | false |
| error | Load failure (renders a retry entry at the bottom) | boolean | false |
| offset | Bottom-hit advance in px | number | 100 |
| immediateCheck | Run a bottom-hit check immediately after mount | boolean | true |
| emptyText | Empty-state text (rendered when finished and there is no content) | string | — |
| ariaLabel | Accessible name | string | — |
| sx | sx quick-layout props | LhSxProps | — |
Events
| Event | Description | Callback |
|---|---|---|
| load | Bottom hit (the consumer flips loading / finished after pulling data) | [] |
| update:error | Retry tap write-back (controlled error cleared) | (value: boolean) |
Slots
| Slot | Description |
|---|---|
| default | List content |
| loading | Loading indicator (spinner by default) |
| finished | "No more items" text (goes through the list.finished language pack by default) |
| error | Error area (a "Load failed, tap to retry" retry entry by default) |
| empty | Empty state (renders emptyText by default) |
Accessibility
- The root element's
aria-busyreflects loading; the accessible name comes fromariaLabel

