Skip to content
↑↓ to navigate↵ to openesc to close

Menu

Infinite Masonry

Preview

Install

Add it with your package manager, or copy the source manually.

Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide

bunx --bun shadcn-vue@latest add @beui-vue/infinite-masonry

Import the shared styles once in your application.

TSUsage
import InfiniteMasonry from '@/components/beui/blocks/InfiniteMasonry.vue'
import '@/components/beui/styles.css'

API Reference

items
readonly Item[]
Default—
getItemKey
(item: Item, index: number) => InfiniteMasonryKey
Default—
#renderItem?
{ item: Item; index: number }

Alias of the default slot, named after the React `renderItem` prop.

Default—
onLoadMore
() => void | Promise<void>

Called when the last few items scroll into view (see `prefetch`).

Default—
hasMore
boolean
Default—
loading?
boolean

A load owned by the consumer, rather than the tail trigger.

Defaultfalse
error?
string

Message rendered in the tail error card, under the heading. Use the `error` slot for markup.

Default—
onRetry?
() => void
Default—
estimateSize?
(item: Item, index: number) => number

Height estimate per item, used to pack the columns until the item is measured.

Default—
#renderLoadingItem?
{ index: number }

Alias of the `loading` slot, named after the React `renderLoadingItem` prop.

Default—
emptyState?
string
Default—
endState?
string
Default—
minColumnWidth?
number
Default208
maxColumns?
number
Default4
gap?
number
Default12
overscan?
number

Rows kept mounted beyond the viewport, in items per column.

Default4
prefetch?
number

Starts a load once an item within this many of the end is visible, counted in items.

Default3
animateItems?
boolean
Defaulttrue
ariaLabel?
string
Default—
class?
string
Default—
contentClassName?
string
Default—
itemClassName?
string
Default—
labels?
Partial<typeof infiniteMasonryMessages>

Override any built-in string.

Default—
#default?
{ item: Item; index: number }

Renders one item.

Default—
#loading?
{ index: number }

Placeholder shown in a column while `loading`.

Default—
#empty?
slot

Shown when there are no items and nothing more to load.

Default—
#emptyState?
slot

Alias of the `empty` slot, named after the React `emptyState` prop.

Default—
#error?
slot

Tail error card details. Render it with `v-if` on the `<template>` so it only exists while loading failed.

Default—
#endState?
slot

Shown under the items once nothing more can load.

Default—

Updated