VirtualListElement
<vaadin-virtual-list> is a Web Component for displaying a virtual/infinite list of items.
<vaadin-virtual-list></vaadin-virtual-list>const list = document.querySelector('vaadin-virtual-list');
list.items = items; // An array of data items
list.renderer = (root, list, {item, index}) => {
root.textContent = `#${index}: ${item.name}`
}Styling
The following state attributes are available for styling:
| Attribute | Description |
|---|---|
overflow | Set to top, bottom, both, or none. |
Built-in Theme Variants
<vaadin-virtual-list> supports the following theme variants:
| Theme variant | Description |
|---|---|
theme="overflow-indicators" | Shows visual indicators at the top and bottom when the content is scrolled |
theme="overflow-indicator-top" | Shows the visual indicator at the top when the content is scrolled |
theme="overflow-indicator-top-bottom" | Shows the visual indicator at the bottom when the content is scrolled |
Custom CSS Properties
The following custom CSS properties are available for styling:
| Custom CSS property |
|---|
--vaadin-virtual-list-overflow-indicator-color |
--vaadin-virtual-list-overflow-indicator-height |
--vaadin-virtual-list-padding-block |
--vaadin-virtual-list-padding-inline |
See Styling Components documentation.
Properties
Gets the index of the first visible item in the viewport.
A function that generates accessible names for virtual list items. The function gets the item as an argument and the return value should be a string representing that item. The result gets applied to the corresponding virtual list child element as an aria-label attribute.
Gets the index of the last visible item in the viewport.
Custom function for rendering the content of every item. Receives three arguments:
Functions
Requests an update for the content of the rows. While performing the update, it invokes the renderer passed in the renderer property for each visible row.
Scroll to a specific index in the virtual list.