Skip to content

Common

CalculateViewLocation = (params) => IndexLocationWithAlign | null | number

ParameterType
paramsCalculateViewLocationParams

IndexLocationWithAlign | null | number


number

The bottom edge position of the item in pixels


number

The top edge position of the item in pixels


locationParams: object & { groupIndex: number; } | { index: number; }

The scroll location parameters including alignment and behavior options


number

The bottom edge position of the viewport in pixels


number

The top edge position of the viewport in pixels


ComputeItemKey<Data, Context> = (index, item, context) => React.Key

Callback type for computing unique keys for list items.

Type ParameterDescription
DataThe type of the data item
ContextThe type of context passed from the component
ParameterType
indexnumber
itemData
contextContext

React.Key

VirtuosoProps.computeItemKey for usage in Virtuoso


Type Parameter
Context

Context

The context value passed from the parent component


How to position the item in the viewport.

LocationOptions.align


Set ‘smooth’ to have an animated transition to the specified location.

LocationOptions.behavior


number | "LAST"

The index of the item to scroll to.


The offset to scroll.

LocationOptions.offset


How to align the item within the viewport

ScrollIntoViewLocationOptions.align


The scroll behavior - ‘smooth’ for animated scrolling, ‘auto’ for instant

ScrollIntoViewLocationOptions.behavior


Use this function to fine-tune the scrollIntoView behavior. The function receives the item’s top and bottom position in the viewport, and the viewport top/bottom. Return an location object to scroll, or null to prevent scrolling. Here’s the default implementation:

ts

ScrollIntoViewLocationOptions.calculateViewLocation


optional done: () => void

Will be called when the scroll is done, or immediately if no scroll is needed.

void

ScrollIntoViewLocationOptions.done


number

The index of the item to scroll into view


FollowOutput = FollowOutputCallback | FollowOutputScalarType


FollowOutputCallback = (isAtBottom) => FollowOutputScalarType

ParameterType
isAtBottomboolean

FollowOutputScalarType


FollowOutputScalarType = "auto" | "smooth" | boolean


IndexLocationWithAlign = FlatIndexLocationWithAlign | GroupIndexLocationWithAlign


Base interface for list items with position and size information.

Type Parameter
Data

The data associated with this item


number

The index of the item in the list


number

The offset position of the item from the start of the list in pixels


number

The measured size of the item in pixels


ListItem<Data> = GroupItem<Data> | RecordItem<Data>

Union type representing either a regular item or a group header item in the list.

Type ParameterDescription
DataThe type of the data item

Represents a range of items in the list by their indices. Used to track which items are currently visible in the viewport.

VirtuosoProps.rangeChanged for visibility change events

number

The index of the last visible item


number

The index of the first visible item


How to position the item in the viewport.


Set ‘smooth’ to have an animated transition to the specified location.


The offset to scroll.


Log levels for controlling virtuoso diagnostic output. Use with the logLevel prop to enable debugging information.

tsx

DEBUG: 0

Detailed debugging information including item measurements


ERROR: 3

Error messages for failures (default level)


INFO: 1

General informational messages


WARN: 2

Warning messages for potential issues


Represents a regular data item (not a group header) in the list.

Type Parameter
Data

The data associated with this item

Item.data


The index of the group this item belongs to (if in a grouped list)


number

The index of the item in the list

Item.index


number

The offset position of the item from the start of the list in pixels

Item.offset


The original index before any transformations were applied


number

The measured size of the item in pixels

Item.size


Undefined for regular items (used to distinguish from group items)


Represents the current scroll state of the container.

number

The total scrollable height of the content in pixels


number

The current scroll position from the top in pixels


number

The visible height of the viewport in pixels


ScrollerProps = Pick<React.ComponentProps<"div">, "children" | "style" | "tabIndex"> & React.RefAttributes<HTMLDivElement> & object

Passed to the Components.Scroller custom component


ScrollIntoViewLocation = FlatScrollIntoViewLocation | GroupedScrollIntoViewLocation


Options for scrolling an item into view.

How to align the item within the viewport


The scroll behavior - ‘smooth’ for animated scrolling, ‘auto’ for instant


Use this function to fine-tune the scrollIntoView behavior. The function receives the item’s top and bottom position in the viewport, and the viewport top/bottom. Return an location object to scroll, or null to prevent scrolling. Here’s the default implementation:

ts

optional done: () => void

Will be called when the scroll is done, or immediately if no scroll is needed.

void


Configuration for scroll seek mode, which renders placeholders during fast scrolling. This improves performance when users scroll rapidly through large lists.

tsx

optional change: (velocity, range) => void

Called during scrolling in scroll seek mode - use to display a hint where the list is.

ParameterType
velocitynumber
rangeListRange

void


ScrollSeekToggle

Callback to determine if the list should enter “scroll seek” mode.


ScrollSeekToggle

Callback to determine if the list should exit “scroll seek” mode.


ScrollSeekToggle = (velocity, range) => boolean

ParameterType
velocitynumber
rangeListRange

boolean


SizeFunction = (el, field) => number

Custom function for calculating item sizes. Override to account for margins, padding, or other layout considerations.

ParameterType
elHTMLElement
field"offsetHeight" | "offsetWidth"

number

VirtuosoProps.itemSize for usage


Represents a range of items that share the same size.

number

The ending index of items in this size range (inclusive)


number

The size in pixels shared by items in this range


number

The starting index of items in this size range


StateCallback = (state) => void

Callback type for receiving state snapshots for persistence.

ParameterType
stateStateSnapshot

void

  • VirtuosoProps.getState for usage
  • StateSnapshot for the snapshot structure

A snapshot of the virtuoso state that can be saved and restored. Use this to persist scroll position and item sizes across page reloads.

SizeRange[]

The measured size ranges of items


number

The scroll position in pixels


Information about the window viewport when using window scrolling mode.

number

The offset from the top of the document to the list container in pixels


number

The visible height of the window viewport in pixels


number

The visible width of the window viewport in pixels