Customize Rendering

The React Virtuoso component renders as several nested DIV elements. The default values in the component prop entries are "div".

components.Scroller (div)
|-viewport (div)
|-header(div* headerFooterTag)
|-components.List (div)
|-components.Group (div+)
|-components.Item (div+)
|-footer(div*, headerFooterTag)
|-components.List (Top Items) (div)
|-components.Item (div+)
|-components.Group (div+)

To change what's rendered, pass your component to the specified key in components. Notice that the List component needs to accept and pass its ref to the actual DOM element. The example below adds borders to each customizable element.


TypeScript Interfaces

The types for each component are available in the Components interface. The example below annotates the Scroller custom component:

import { Components } from 'react-virtuoso'
const Scroller: Components['Scroller'] = React.forwardRef(({ style, children }, ref) => {
return (
<div style={style} ref={ref}>