Skip to content

InfiniteScrollSelect

A vue-select wrapper that triggers a load-more callback when the user scrolls to the bottom of the dropdown options. Designed for large datasets loaded from an API.

Usage

vue
<script setup>
import { ref } from 'vue'
import { InfiniteScrollSelect } from 'praxis-vue-ui'

const options = ref([/* initial page */])
const hasMore = ref(true)
const loading = ref(false)

const loadMore = async () => {
  loading.value = true
  const newItems = await api.getNextPage()
  options.value.push(...newItems)
  loading.value = false
}
</script>

<template>
  <InfiniteScrollSelect
    v-model="selected"
    :options="options"
    :has-more="hasMore"
    :loading-scroll="loading"
    :load-more-scroll="loadMore"
    placeholder="Search providers..."
  />
</template>

Props

PropTypeDefaultDescription
modelValueunknownnullCurrently selected value. Use with v-model.
optionsrequiredunknown[]Current page of loaded options.
hasMorebooleanfalseWhether more items are available to load from the server.
loadingScrollbooleanfalseShows a spinner at the bottom of the dropdown while loading.
loadMoreScroll() => Promise<void>undefinedAsync callback invoked when the user scrolls to the bottom of the dropdown.
placeholderstring''Placeholder text.
labelstring'name'Property name used as display label.
reduce(option) => unknownundefinedValue extractor function.
disabledbooleanfalseDisables the select.
searchFunction(query: string) => voidundefinedCustom search handler (server-side search).

Emits

EventPayloadDescription
update:modelValueunknownEmitted on selection change.

Built with VitePress