Handle massive amounts of data without slowing down your web browser. Whether you’re showing 50 or 5,000 items, dynamic lists offer a smooth user experience by using virtualization to render items as you scroll.
Where: This change applies to Lightning Experience, Experience Builder sites, and all versions of the mobile app in all editions. This change is available only to organizations that have opted in to the Dev channel in Salesforce Release Manager.
How: To use dynamic lists, opt in to the Dev channel in Salesforce Release Manager.
In your custom component, use the lightning-dynamic-list-container and lightning-dynamic-list-item base components.
To work with dynamic lists:
- Place the dynamic list components in a container with a bounded height. The height constraint ensures proper rendering and scroll behavior.
- Wrap the entire list with
lightning-dynamic-list-container. - Wrap each row with
lightning-dynamic-list-item. - Use a unique
item-idon each item so that the component can track focus correctly even when items scroll off-screen. - Attach the
renderlistitemsevent listener tolightning-dynamic-list-container. When you scroll, the component continuously dispatches the event to inform the parent which sliced list to render. When the sliced list renders, the component adjusts the position of each row.
Dynamic lists provide these functionalities.
- List virtualization with infinite scrolling: The list dispatches a
loadmoreevent to notify the parent component to load additional rows. It loads only the items currently visible in the user's window, which significantly reduces browser memory usage. - Focus preservation: The list keeps track of the focused row, maintaining focus even during virtualization. Even if you click a row and scroll it off-screen, the list ensures focus is maintained.
- Comprehensive accessibility: The list provides native support for screen readers and keyboard navigation. It automatically handles complex interactions like Home, End, and Arrow key navigation. With Browse Mode detection, the list also identifies when a keyboard user is navigating without triggering standard focus events and announces a live message suggesting that they switch to Focus Mode to ensure that the virtual cursor and the scrolling list remain perfectly aligned.
Here are some considerations for working with dynamic lists.
- Place
lightning-dynamic-list-containeradjacent tolightning-dynamic-list-item. Embedding elements or other components between the dynamic list components isn’t supported. - Place both
lightning-dynamic-list-containerandlightning-dynamic-list-itemin the same LWC template. - Avoid padding on elements between
lightning-dynamic-list-containerandlightning-dynamic-list-item. Use margin on rows wrapped bylightning-dynamic-list-itemfor spacing between rows and between rows and the container. - Remove
overflow: scrollor similar styles from your list container.lightning-dynamic-list-containerhandles scrolling on dynamic lists.