Virtuoso Grid API Reference

All properties are optional - by default, the component will render empty.

If you are using TypeScript and want to use correctly typed component ref, you can use VirtuosoGridHandle types.

import { VirtuosoGrid, VirtuosoGridHandle } from 'react-virtuoso'
//...
const ref = useRef<VirtuosoGridHandle>(null)
//...
<VirtuosoGrid ref={ref} /*...*/ />

Properties

"components".VirtuosoGridProps

Hierarchy

  • unknown

    VirtuosoGridProps

Properties

atBottomStateChange

Optional atBottomStateChange: (atBottom: boolean) => void

Defined in components.tsx:282

Called with true / false when the list has reached the bottom / gets scrolled up. Can be used to load newer items, like tail -f.


atTopStateChange

Optional atTopStateChange: (atTop: boolean) => void

Defined in components.tsx:287

Called with true / false when the list has reached the top / gets scrolled down.


components

Optional components: GridProps["components"]

Defined in components.tsx:236

Use the components property for advanced customization of the elements rendered by the list.


computeItemKey

Optional computeItemKey: GridProps["computeItemKey"]

Defined in components.tsx:248

If specified, the component will use the function to generate the key property for each list item.


endReached

Optional endReached: (index: number) => void

Defined in components.tsx:266

Gets called when the user scrolls to the end of the list. Receives the last item index as an argument. Can be used to implement endless scrolling.


isScrolling

Optional isScrolling: (isScrolling: boolean) => void

Defined in components.tsx:260

Called when the list starts/stops scrolling.


itemClassName

Optional itemClassName: string

Defined in components.tsx:302

Sets the grid items' className


itemContent

Optional itemContent: GridProps["itemContent"]

Defined in components.tsx:231

Set the callback to specify the contents of the item.


listClassName

Optional listClassName: string

Defined in components.tsx:297

Sets the className for the list DOM element


overscan

Optional overscan: number | { main: number ; reverse: number }

Defined in components.tsx:243

Set the overscan property to make the component "chunk" the rendering of new items on scroll. The property causes the component to render more items than the necessary, but reduces the re-renders on scroll. Setting { main: number, reverse: number } lets you extend the list in both the main and the reverse scrollable directions.


rangeChanged

Optional rangeChanged: (range: ListRange) => void

Defined in components.tsx:276

Called with the new set of items each time the list items are rendered due to scrolling.


scrollSeekConfiguration

Optional scrollSeekConfiguration: ScrollSeekConfiguration | false

Defined in components.tsx:255

Use to display placeholders if the user scrolls fast through the list.

Set components.ScrollSeekPlaceholder to change the placeholder content.


scrollerRef

Optional scrollerRef: (ref: HTMLElement | null) => any

Defined in components.tsx:292

Provides access to the root DOM element


startReached

Optional startReached: (index: number) => void

Defined in components.tsx:271

Called when the user scrolls to the start of the list.


totalCount

totalCount: GridProps["totalCount"]

Defined in components.tsx:226

The total amount of items to be rendered.


useWindowScroll

Optional useWindowScroll: boolean

Defined in components.tsx:307

Uses the document scroller rather than wrapping the grid in its own.

Methods

"components".VirtuosoHandle

Hierarchy

  • {}

    VirtuosoHandle

Methods

scrollBy

scrollBy(location: ScrollToOptions): void

Defined in components.tsx:322

Scrolls the component with the specified amount. See ScrollToOptions (MDN)

Parameters:

NameType
locationScrollToOptions

Returns: void


scrollTo

scrollTo(location: ScrollToOptions): void

Defined in components.tsx:318

Scrolls the component to the specified location. See ScrollToOptions (MDN)

Parameters:

NameType
locationScrollToOptions

Returns: void


scrollToIndex

scrollToIndex(location: number | IndexLocationWithAlign): void

Defined in components.tsx:314

Scrolls the component to the specified item index. See {{IndexLocationWithAlign}} for more options.

Parameters:

NameType
locationnumber | IndexLocationWithAlign

Returns: void