Common
CalculateViewLocation
Section titled “CalculateViewLocation”CalculateViewLocation = (
params) =>IndexLocationWithAlign|null|number
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
params | CalculateViewLocationParams |
Returns
Section titled “Returns”IndexLocationWithAlign | null | number
CalculateViewLocationParams
Section titled “CalculateViewLocationParams”Properties
Section titled “Properties”itemBottom
Section titled “itemBottom”number
The bottom edge position of the item in pixels
itemTop
Section titled “itemTop”number
The top edge position of the item in pixels
locationParams
Section titled “locationParams”locationParams:
object& {groupIndex:number; } | {index:number; }
The scroll location parameters including alignment and behavior options
Type Declaration
Section titled “Type Declaration”align?: "start" | "center" | "end"
Section titled “align?: "start" | "center" | "end"”behavior?: "auto" | "smooth"
Section titled “behavior?: "auto" | "smooth"”viewportBottom
Section titled “viewportBottom”number
The bottom edge position of the viewport in pixels
viewportTop
Section titled “viewportTop”number
The top edge position of the viewport in pixels
ComputeItemKey
Section titled “ComputeItemKey”ComputeItemKey<
Data,Context> = (index,item,context) =>React.Key
Callback type for computing unique keys for list items.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
Data | The type of the data item |
Context | The type of context passed from the component |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
index | number |
item | Data |
context | Context |
Returns
Section titled “Returns”React.Key
VirtuosoProps.computeItemKey for usage in Virtuoso
ContextProp
Section titled “ContextProp”Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Context |
Properties
Section titled “Properties”context
Section titled “context”Context
The context value passed from the parent component
FlatIndexLocationWithAlign
Section titled “FlatIndexLocationWithAlign”Extends
Section titled “Extends”Properties
Section titled “Properties”align?: "start" | "center" | "end"
Section titled “align?: "start" | "center" | "end"”How to position the item in the viewport.
Inherited from
Section titled “Inherited from”behavior?: "auto" | "smooth"
Section titled “behavior?: "auto" | "smooth"”Set ‘smooth’ to have an animated transition to the specified location.
Inherited from
Section titled “Inherited from”number | "LAST"
The index of the item to scroll to.
offset?: number
Section titled “offset?: number”The offset to scroll.
Inherited from
Section titled “Inherited from”FlatScrollIntoViewLocation
Section titled “FlatScrollIntoViewLocation”Extends
Section titled “Extends”Properties
Section titled “Properties”align?: "start" | "center" | "end"
Section titled “align?: "start" | "center" | "end"”How to align the item within the viewport
Inherited from
Section titled “Inherited from”ScrollIntoViewLocationOptions.align
behavior?: "auto" | "smooth"
Section titled “behavior?: "auto" | "smooth"”The scroll behavior - ‘smooth’ for animated scrolling, ‘auto’ for instant
Inherited from
Section titled “Inherited from”ScrollIntoViewLocationOptions.behavior
calculateViewLocation?: CalculateViewLocation
Section titled “calculateViewLocation?: CalculateViewLocation”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:
tsInherited from
Section titled “Inherited from”ScrollIntoViewLocationOptions.calculateViewLocation
done()?
Section titled “done()?”
optionaldone: () =>void
Will be called when the scroll is done, or immediately if no scroll is needed.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ScrollIntoViewLocationOptions.done
number
The index of the item to scroll into view
FollowOutput
Section titled “FollowOutput”FollowOutput =
FollowOutputCallback|FollowOutputScalarType
FollowOutputCallback
Section titled “FollowOutputCallback”FollowOutputCallback = (
isAtBottom) =>FollowOutputScalarType
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
isAtBottom | boolean |
Returns
Section titled “Returns”FollowOutputScalarType
Section titled “FollowOutputScalarType”FollowOutputScalarType =
"auto"|"smooth"|boolean
IndexLocationWithAlign
Section titled “IndexLocationWithAlign”IndexLocationWithAlign =
FlatIndexLocationWithAlign|GroupIndexLocationWithAlign
Base interface for list items with position and size information.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Data |
Properties
Section titled “Properties”data?: Data
Section titled “data?: Data”The data associated with this item
number
The index of the item in the list
offset
Section titled “offset”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
Section titled “ListItem”ListItem<
Data> =GroupItem<Data> |RecordItem<Data>
Union type representing either a regular item or a group header item in the list.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
Data | The type of the data item |
- RecordItem for regular items
- GroupItem for group header items
ListRange
Section titled “ListRange”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
Properties
Section titled “Properties”endIndex
Section titled “endIndex”number
The index of the last visible item
startIndex
Section titled “startIndex”number
The index of the first visible item
LocationOptions
Section titled “LocationOptions”Extended by
Section titled “Extended by”Properties
Section titled “Properties”align?: "start" | "center" | "end"
Section titled “align?: "start" | "center" | "end"”How to position the item in the viewport.
behavior?: "auto" | "smooth"
Section titled “behavior?: "auto" | "smooth"”Set ‘smooth’ to have an animated transition to the specified location.
offset?: number
Section titled “offset?: number”The offset to scroll.
LogLevel
Section titled “LogLevel”Log levels for controlling virtuoso diagnostic output.
Use with the logLevel prop to enable debugging information.
Example
Section titled “Example”tsxEnumeration Members
Section titled “Enumeration Members”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
RecordItem
Section titled “RecordItem”Represents a regular data item (not a group header) in the list.
Extends
Section titled “Extends”Item<Data>
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Data |
Properties
Section titled “Properties”data?: Data
Section titled “data?: Data”The data associated with this item
Overrides
Section titled “Overrides”groupIndex?: number
Section titled “groupIndex?: number”The index of the group this item belongs to (if in a grouped list)
number
The index of the item in the list
Inherited from
Section titled “Inherited from”offset
Section titled “offset”number
The offset position of the item from the start of the list in pixels
Inherited from
Section titled “Inherited from”originalIndex?: number
Section titled “originalIndex?: number”The original index before any transformations were applied
number
The measured size of the item in pixels
Inherited from
Section titled “Inherited from”type?: undefined
Section titled “type?: undefined”Undefined for regular items (used to distinguish from group items)
ScrollContainerState
Section titled “ScrollContainerState”Represents the current scroll state of the container.
Properties
Section titled “Properties”scrollHeight
Section titled “scrollHeight”number
The total scrollable height of the content in pixels
scrollTop
Section titled “scrollTop”number
The current scroll position from the top in pixels
viewportHeight
Section titled “viewportHeight”number
The visible height of the viewport in pixels
ScrollerProps
Section titled “ScrollerProps”ScrollerProps =
Pick<React.ComponentProps<"div">,"children"|"style"|"tabIndex"> &React.RefAttributes<HTMLDivElement> &object
Passed to the Components.Scroller custom component
Type Declaration
Section titled “Type Declaration”data-testid?: string
Section titled “data-testid?: string”data-virtuoso-scroller?: boolean
Section titled “data-virtuoso-scroller?: boolean”ScrollIntoViewLocation
Section titled “ScrollIntoViewLocation”ScrollIntoViewLocation =
FlatScrollIntoViewLocation|GroupedScrollIntoViewLocation
ScrollIntoViewLocationOptions
Section titled “ScrollIntoViewLocationOptions”Options for scrolling an item into view.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”align?: "start" | "center" | "end"
Section titled “align?: "start" | "center" | "end"”How to align the item within the viewport
behavior?: "auto" | "smooth"
Section titled “behavior?: "auto" | "smooth"”The scroll behavior - ‘smooth’ for animated scrolling, ‘auto’ for instant
calculateViewLocation?: CalculateViewLocation
Section titled “calculateViewLocation?: CalculateViewLocation”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:
tsdone()?
Section titled “done()?”
optionaldone: () =>void
Will be called when the scroll is done, or immediately if no scroll is needed.
Returns
Section titled “Returns”void
ScrollSeekConfiguration
Section titled “ScrollSeekConfiguration”Configuration for scroll seek mode, which renders placeholders during fast scrolling. This improves performance when users scroll rapidly through large lists.
Example
Section titled “Example”tsx- VirtuosoProps.scrollSeekConfiguration for usage
- Components.ScrollSeekPlaceholder for custom placeholder rendering
Properties
Section titled “Properties”change()?
Section titled “change()?”
optionalchange: (velocity,range) =>void
Called during scrolling in scroll seek mode - use to display a hint where the list is.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
velocity | number |
range | ListRange |
Returns
Section titled “Returns”void
Callback to determine if the list should enter “scroll seek” mode.
Callback to determine if the list should exit “scroll seek” mode.
ScrollSeekToggle
Section titled “ScrollSeekToggle”ScrollSeekToggle = (
velocity,range) =>boolean
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
velocity | number |
range | ListRange |
Returns
Section titled “Returns”boolean
SizeFunction
Section titled “SizeFunction”SizeFunction = (
el,field) =>number
Custom function for calculating item sizes. Override to account for margins, padding, or other layout considerations.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
el | HTMLElement |
field | "offsetHeight" | "offsetWidth" |
Returns
Section titled “Returns”number
VirtuosoProps.itemSize for usage
SizeRange
Section titled “SizeRange”Represents a range of items that share the same size.
Properties
Section titled “Properties”endIndex
Section titled “endIndex”number
The ending index of items in this size range (inclusive)
number
The size in pixels shared by items in this range
startIndex
Section titled “startIndex”number
The starting index of items in this size range
StateCallback
Section titled “StateCallback”StateCallback = (
state) =>void
Callback type for receiving state snapshots for persistence.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state | StateSnapshot |
Returns
Section titled “Returns”void
- VirtuosoProps.getState for usage
- StateSnapshot for the snapshot structure
StateSnapshot
Section titled “StateSnapshot”A snapshot of the virtuoso state that can be saved and restored. Use this to persist scroll position and item sizes across page reloads.
- VirtuosoProps.restoreStateFrom for restoring state
- VirtuosoHandle.getState for capturing state
Properties
Section titled “Properties”ranges
Section titled “ranges”The measured size ranges of items
scrollTop
Section titled “scrollTop”number
The scroll position in pixels
WindowViewportInfo
Section titled “WindowViewportInfo”Information about the window viewport when using window scrolling mode.
Properties
Section titled “Properties”offsetTop
Section titled “offsetTop”number
The offset from the top of the document to the list container in pixels
visibleHeight
Section titled “visibleHeight”number
The visible height of the window viewport in pixels
visibleWidth
Section titled “visibleWidth”number
The visible width of the window viewport in pixels