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

Type parameters

NameTypeDefault
Cunknownunknown

Hierarchy

  • {}

    VirtuosoGridProps

Properties

atBottomStateChange

Optional atBottomStateChange: (atBottom: boolean) => void

Defined in src/components.tsx:530

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 src/components.tsx:535

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


components

Optional components: GridComponents<C>

Defined in src/components.tsx:484

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


computeItemKey

Optional computeItemKey: GridComputeItemKey

Defined in src/components.tsx:496

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


customScrollParent

Optional customScrollParent: HTMLElement

Defined in src/components.tsx:560

Pass a reference to a scrollable parent element, so that the grid won't wrap in its own.


endReached

Optional endReached: (index: number) => void

Defined in src/components.tsx:514

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 src/components.tsx:508

Called when the list starts/stops scrolling.


itemClassName

Optional itemClassName: string

Defined in src/components.tsx:550

Sets the grid items' className


itemContent

Optional itemContent: GridItemContent<C>

Defined in src/components.tsx:479

Set the callback to specify the contents of the item.


listClassName

Optional listClassName: string

Defined in src/components.tsx:545

Sets the className for the list DOM element


overscan

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

Defined in src/components.tsx:491

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 src/components.tsx:524

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


scrollSeekConfiguration

Optional scrollSeekConfiguration: ScrollSeekConfiguration | false

Defined in src/components.tsx:503

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 src/components.tsx:540

Provides access to the root DOM element


startReached

Optional startReached: (index: number) => void

Defined in src/components.tsx:519

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


totalCount

totalCount: number

Defined in src/components.tsx:474

The total amount of items to be rendered.


useWindowScroll

Optional useWindowScroll: boolean

Defined in src/components.tsx:555

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 src/components.tsx:579

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

Parameters:

NameType
locationScrollToOptions

Returns: void


scrollIntoView

scrollIntoView(location: FlatScrollIntoViewLocation): void

Defined in src/components.tsx:571

Scrolls the item into view if necessary. See the website example for an implementation.

Parameters:

NameType
locationFlatScrollIntoViewLocation

Returns: void


scrollTo

scrollTo(location: ScrollToOptions): void

Defined in src/components.tsx:575

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

Parameters:

NameType
locationScrollToOptions

Returns: void


scrollToIndex

scrollToIndex(location: number | FlatIndexLocationWithAlign): void

Defined in src/components.tsx:567

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

Parameters:

NameType
locationnumber | FlatIndexLocationWithAlign

Returns: void