ng-virtual-list
Version:
π High-performance virtual scrolling for Angular apps. Render 100,000+ items in Angular without breaking a sweat. Smooth, customizable, and developer-friendly.
712 lines (559 loc) β’ 28.6 kB
Markdown
# NgVirtualList
π High-performance virtual scrolling for Angular apps. Render 100,000+ items in Angular without breaking a sweat. Smooth, customizable, and developer-friendly.
Flexible, and actively maintained Angular library that excels with high-performance, feature-rich virtualized listsβincluding grouping, sticky headers, snapping, animations, collapsing group elements, single and multiple selection of elements and both scroll directions. Whether you're rendering millions of items or building interactive list components, it delivers scalability and customization. Angular (14β20) compatibility.
<img width="1033" height="171" alt="logo" src="https://github.com/user-attachments/assets/b559cfde-405a-4361-b71b-6715478d997d" />
<b>Angular version 20.X.X</b>.



[Live Demo](https://ng-virtual-list-chat-demo.eugene-grebennikov.pro/)
[(Code)](https://github.com/DjonnyX/ng-virtual-list-demo)
[Live Examples (Storybook)](https://ng-virtual-list-examples.eugene-grebennikov.pro/)
[Examples](https://ng-virtual-list.eugene-grebennikov.pro/)
[(Code)](https://github.com/DjonnyX/ng-virtual-list-demo/tree/main/src/app)
<br/>
## β¨ Why use ng-virtual-list?
β‘ Blazing fast β only renders whatβs visible (plus a smart buffer).<br/>
π± Works everywhere β smooth on desktop & mobile.<br/>
π Flexible layouts β vertical, horizontal, grouped lists, sticky headers.<br/>
π Dynamic sizes β handles items of varying height/width.<br/>
π Precise control β scroll to an ID, or snap to positions.<br/>
β
Selecting elements β ability to work in Select and MultiSelect modes.<br/>
π§© Collapsing group elements β ability to collapse group elements (elements with the "stickiness" parameter).<br/>
<br/>
## βοΈ Key Features
Virtualization modes
- Fixed size (fastest)
- Dynamic size (auto-measured)
- Scrolling control
- Scroll to item ID
- Smooth or instant scroll
- Custom snapping behavior
- Advanced layouts
- Grouped lists with sticky headers
- Horizontal or vertical scrolling
- Selecting elements
- Single selection
- Multiple selection
- Performance tuning
- bufferSize and maxBufferSize for fine-grained control
- Collapsing groups
- collapse group elements
<br/>
## π± When to Use It: Ideal Use Cases
Drawing on general virtual-scroll insights and ng-virtual-list features:
Long-Scrolling Lists / Live Feeds
When displaying hundreds of thousands of items (think social media feeds, chat logs, or news streams), ng-virtual-list ensures smooth and responsive rendering without overwhelming the browser.
Horizontal Carousels or Galleries
Ideal for media-rich UI elements like image galleries, product cards, or horizontal scrollers where traditional ngFor rendering becomes sluggish.
Grouped Navigation with Section Headers
For catalogs, logs, or grouped entries (e.g., by date or category), you can use sticky headers and snapping to guide user navigation effectively.
"Jump to" Item Navigation
Use cases like directories or chat histories benefit from the ability to scroll directly to specific items by ID.
Complex or Rich-Content Templates
As each item may contain images, nested components, or interactions, virtual rendering keeps performance intact even when item complexity increases.
Single and multiple selection of elements
Navigating with the keyboard
Collapsing groups
Support for element animation
<br/>
## π¦ Installation
```bash
npm i ng-virtual-list
```
<br/>
## π Quick Start
```html
<ng-virtual-list [items]="items" [bufferSize]="5" [itemRenderer]="itemRenderer" [itemSize]="64"></ng-virtual-list>
<ng-template #itemRenderer let-data="data">
(data) {
<span>{{data.name}}</span>
}
</ng-template>
```
```ts
items = Array.from({ length: 100000 }, (_, i) => ({ id: i, name: `Item #${i}` }));
```
<br/>
## π± Examples
### Horizontal virtual list (Single selection)

Template:
```html
<ng-virtual-list class="list" direction="horizontal" [items]="horizontalItems" [bufferSize]="5" [maxBufferSize]="20"
[itemRenderer]="horizontalItemRenderer" [itemSize]="64" [methodForSelecting]="'select'"
[selectedIds]="2" (onSelect)="onSelect($event)" (onItemClick)="onItemClick($event)"></ng-virtual-list>
<ng-template #horizontalItemRenderer let-data="data" let-config="config">
(data) {
<div [ngClass]="{'list__h-container': true, 'selected': config.selected}">
<span>{{data.name}}</span>
</div>
}
</ng-template>
```
Component:
```ts
import { NgVirtualListComponent, IVirtualListCollection, IRenderVirtualListItem } from 'ng-virtual-list';
interface ICollectionItem {
name: string;
}
const HORIZONTAL_ITEMS: IVirtualListCollection<ICollectionItem> = Array.from({ length: 100000 }, (_, i) => ({ id: i, name: `${i}` }));
({
selector: 'app-root',
imports: [NgVirtualListComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
horizontalItems = HORIZONTAL_ITEMS;
onItemClick(item: IRenderVirtualListItem<ICollectionItem> | undefined) {
if (item) {
console.info(`Click: (ID: ${item.id}) Item ${item.data.name}`);
}
}
onSelect(data: Array<Id> | Id | undefined) {
console.info(`Select: ${JSON.stringify(data)}`);
}
}
```
### Horizontal grouped virtual list (Multiple selection)

Template:
```html
<ng-virtual-list class="list" direction="horizontal" [items]="horizontalGroupItems" [itemRenderer]="horizontalGroupItemRenderer"
[bufferSize]="5" [maxBufferSize]="20" [itemConfigMap]="horizontalGroupItemConfigMap" [itemSize]="54" [snap]="true"
methodForSelecting="multi-select" [selectedIds]="[3,2]" (onSelect)="onSelect($event)" (onItemClick)="onItemClick($event)"></ng-virtual-list>
<ng-template #horizontalGroupItemRenderer let-data="data" let-config="config">
(data) {
(data.type) {
("group-header") {
<div class="list__h-group-container">
<span>{{data.name}}</span>
</div>
}
{
<div [ngClass]="{'list__h-container': true, 'selected': config.selected}">
<span>{{data.name}}</span>
</div>
}
}
}
</ng-template>
```
Component:
```ts
import { NgVirtualListComponent, IVirtualListCollection, IVirtualListItemConfigMap, IRenderVirtualListItem } from 'ng-virtual-list';
const GROUP_NAMES = ['A', 'B', 'C', 'D', 'E'];
const getGroupName = () => {
return GROUP_NAMES[Math.floor(Math.random() * GROUP_NAMES.length)];
};
interface ICollectionItem {
type: 'group-header' | 'item';
name: string;
}
const HORIZONTAL_GROUP_ITEMS: IVirtualListCollection<ICollectionItem> = [],
HORIZONTAL_GROUP_ITEM_CONFIG_MAP: IVirtualListItemConfigMap = {};
for (let i = 0, l = 1000000; i < l; i++) {
const id = i + 1, type = Math.random() > .895 ? 'group-header' : 'item';
HORIZONTAL_GROUP_ITEMS.push({ id, type, name: type === 'group-header' ? getGroupName() : `${i}` });
HORIZONTAL_GROUP_ITEM_CONFIG_MAP[id] = type === 'group-header' ? 1 : 0;
}
({
selector: 'app-root',
imports: [NgVirtualListComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
horizontalGroupItems = HORIZONTAL_GROUP_ITEMS;
horizontalGroupItemConfigMap = HORIZONTAL_GROUP_ITEM_CONFIG_MAP;
onItemClick(item: IRenderVirtualListItem<ICollectionItem> | undefined) {
if (item) {
console.info(`Click: (ID: ${item.id}) Item ${item.data.name}`);
}
}
onSelect(data: Array<Id> | Id | undefined) {
console.info(`Select: ${JSON.stringify(data)}`);
}
}
```
### Vertical virtual list

Template:
```html
<ng-virtual-list class="list simple" [items]="items" [bufferSize]="5" [maxBufferSize]="20" [itemRenderer]="itemRenderer"
[itemSize]="40"></ng-virtual-list>
<ng-template #itemRenderer let-data="data">
(data) {
<div class="list__container">
<p>{{data.name}}</p>
</div>
}
</ng-template>
```
Component:
```ts
import { NgVirtualListComponent, IVirtualListCollection } from 'ng-virtual-list';
const ITEMS: IVirtualListCollection = [];
for (let i = 0, l = 100000; i < l; i++) {
ITEMS.push({ id: i, name: `Item: ${i}` });
}
({
selector: 'app-root',
imports: [NgVirtualListComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
items = ITEMS;
}
```
### Vertical grouped virtual list
#### Without snapping

Template:
```html
<ng-virtual-list class="list simple" [items]="groupItems" [bufferSize]="5" [maxBufferSize]="20" [itemRenderer]="groupItemRenderer"
[itemConfigMap]="groupItemConfigMap" [itemSize]="40" [snap]="false"></ng-virtual-list>
<ng-template #groupItemRenderer let-data="data">
(data) {
(data.type) {
("group-header") {
<div class="list__group-container">
<p>{{data.name}}</p>
</div>
}
{
<div class="list__container">
<p>{{data.name}}</p>
</div>
}
}
}
</ng-template>
```
#### With snapping

Template (with snapping):
```html
<ng-virtual-list class="list simple" [items]="groupItems" [bufferSize]="5" [maxBufferSize]="20" [itemRenderer]="groupItemRenderer"
[itemConfigMap]="groupItemConfigMap" [itemSize]="40" [snap]="true"></ng-virtual-list>
<ng-template #groupItemRenderer let-data="data">
(data) {
(data.type) {
("group-header") {
<div class="list__group-container">
<p>{{data.name}}</p>
</div>
}
{
<div class="list__container">
<p>{{data.name}}</p>
</div>
}
}
}
</ng-template>
```
Component:
```ts
import { NgVirtualListComponent, IVirtualListCollection, IVirtualListItemConfigMap } from 'ng-virtual-list';
const GROUP_ITEMS: IVirtualListCollection = [],
GROUP_ITEM_CONFIG_MAP: IVirtualListItemConfigMap = {};
let groupIndex = 0;
for (let i = 0, l = 10000000; i < l; i++) {
const id = i, type = Math.random() > .895 ? 'group-header' : 'item';
if (type === 'group-header') {
groupIndex++;
}
GROUP_ITEMS.push({ id, type, name: type === 'group-header' ? `Group ${groupIndex}` : `Item: ${i}` });
GROUP_ITEM_CONFIG_MAP[id] = type === 'group-header' ? 1 : 0;
}
({
selector: 'app-root',
imports: [NgVirtualListComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
groupItems = GROUP_ITEMS;
groupItemConfigMap = GROUP_ITEM_CONFIG_MAP;
}
```
### ScrollTo
The example demonstrates the scrollTo method by passing it the element id. It is important not to confuse the ordinal index and the element id. In this example, id = index + 1

Template
```html
<div class="scroll-to__controls">
<input type="number" class="scroll-to__input" [(ngModel)]="itemId" [required]="true" [min]="items[0].id"
[max]="items[items.length - 1].id">
<button class="scroll-to__button" (click)="onButtonScrollToIdClickHandler($event)">Scroll</button>
</div>
<ng-virtual-list #virtualList class="list" [items]="items" [itemRenderer]="itemRenderer" [bufferSize]="5" [maxBufferSize]="20"
[itemSize]="40"></ng-virtual-list>
<ng-template #itemRenderer let-data="data">
(data) {
<div class="list__container">
<span>{{data.name}}</span>
</div>
}
</ng-template>
```
Component
```ts
import { NgVirtualListComponent, IVirtualListCollection, Id } from 'ng-virtual-list';
const MAX_ITEMS = 1000000;
const ITEMS: IVirtualListCollection = [];
for (let i = 0, l = MAX_ITEMS; i < l; i++) {
ITEMS.push({ id: i + 1, name: `Item: ${i}` });
}
({
selector: 'app-root',
imports: [FormsModule, NgVirtualListComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
protected _listContainerRef = viewChild('virtualList', { read: NgVirtualListComponent });
items = ITEMS;
itemId: Id = this.items[0].id;
onButtonScrollToIdClickHandler = (e: Event) => {
const list = this._listContainerRef();
if (list) {
list.scrollTo(this.itemId, 'smooth');
}
}
}
```
### Virtual list (with dynamic item size)
Virtual list with height-adjustable elements.

Template
```html
<ng-virtual-list #dynamicList class="list" [items]="groupDynamicItems" [itemRenderer]="groupItemRenderer" [bufferSize]="5" [maxBufferSize]="20"
[itemConfigMap]="groupDynamicItemConfigMap" [dynamicSize]="true" [snap]="true"></ng-virtual-list>
<ng-template #groupItemRenderer let-data="data">
(data) {
(data.type) {
("group-header") {
<div class="list__group-container">
<span>{{data.name}}</span>
</div>
}
{
<div class="list__container">
<span>{{data.name}}</span>
</div>
}
}
}
</ng-template>
```
Component
```ts
import { NgVirtualListComponent, IVirtualListCollection } from 'ng-virtual-list';
const CHARS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
const generateLetter = () => {
return CHARS[Math.round(Math.random() * CHARS.length)];
}
const generateWord = () => {
const length = 5 + Math.floor(Math.random() * 50), result = [];
while (result.length < length) {
result.push(generateLetter());
}
return `${result.join('')}`;
};
const generateText = () => {
const length = 2 + Math.floor(Math.random() * 10), result = [];
while (result.length < length) {
result.push(generateWord());
}
result[0] = result[0].toUpperCase();
return `${result.join(' ')}.`;
};
const GROUP_DYNAMIC_ITEMS: IVirtualListCollection = [],
GROUP_DYNAMIC_ITEM_CONFIG_MAP: IVirtualListItemConfigMap = {};
let groupDynamicIndex = 0;
for (let i = 0, l = 100000; i < l; i++) {
const id = i + 1, type = i === 0 || Math.random() > .895 ? 'group-header' : 'item';
if (type === 'group-header') {
groupDynamicIndex++;
}
GROUP_DYNAMIC_ITEMS.push({ id, type, name: type === 'group-header' ? `Group ${groupDynamicIndex}` : `${id}. ${generateText()}` });
GROUP_DYNAMIC_ITEM_CONFIG_MAP[id] = type === 'group-header' ? 1 : 0;
}
({
selector: 'app-root',
imports: [FormsModule, NgVirtualListComponent],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
groupDynamicItems = GROUP_DYNAMIC_ITEMS;
groupDynamicItemConfigMap = GROUP_DYNAMIC_ITEM_CONFIG_MAP;
}
```
<br/>
## πΌοΈ Stylization
List items are encapsulated in shadowDOM, so to override default styles you need to use ::part access
- Customize a scroll area of list
```css
.list::part(scroller) {
scroll-behavior: auto;
/* custom scrollbar */
&::-webkit-scrollbar {
width: 16px;
height: 16px;
}
&::-webkit-scrollbar-track {
background-color: #ffffff;
}
&::-webkit-scrollbar-thumb {
background-color: #d6dee1;
border-radius: 20px;
border: 6px solid transparent;
background-clip: content-box;
min-width: 60px;
min-height: 60px;
}
&::-webkit-scrollbar-thumb:hover {
background-color: #a8bbbf;
}
}
.list {
border-radius: 3px;
box-shadow: 1px 2px 8px 4px rgba(0, 0, 0, 0.075);
border: 1px solid rgba(0, 0, 0, 0.1);
}
```
- Set up the list item canvas
```css
.list::part(list) {
background-color: #ffffff;
}
```
- Set up the snapped item (Only SnappingMethod.ADVANCED)
```css
.list::part(snapped-item) {
color: #71718c;
}
```
- Set up the list item
```css
.list::part(item) {
background-color: unset; // override default styles
}
```
Selecting even elements:
```html
<ng-virtual-list class="list" direction="horizontal" [items]="horizontalItems" [bufferSize]="5" [maxBufferSize]="20"
[itemRenderer]="horizontalItemRenderer" [itemSize]="54"></ng-virtual-list>
<ng-template #horizontalItemRenderer let-data="data" let-config="config">
(data) {
<div [ngClass]="{'item-container': true, 'even': config.even}">
<span>{{data.name}}</span>
</div>
}
</ng-template>
```
```css
.item-container {
&.even {
background-color: #1d1d21;
}
}
```
<br/>
## π API
### [NgVirtualListComponent](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/ng-virtual-list.component.ts)
Inputs
| Property | Type | Description |
|---|---|---|
| id | number | Readonly. Returns the unique identifier of the component. |
| items | [IVirtualListCollection](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/collection.model.ts) | Collection of list items. The collection of elements must be immutable. |
| itemSize | number? = 24 | If direction = 'vertical', then the height of a typical element. If direction = 'horizontal', then the width of a typical element. Ignored if the dynamicSize property is true. |
| bufferSize | number? = 2 | Number of elements outside the scope of visibility. Default value is 2. |
| maxBufferSize | number? = 10 | Maximum number of elements outside the scope of visibility. Default value is 10. If maxBufferSize is set to be greater than bufferSize, then adaptive buffer mode is enabled. The greater the scroll size, the more elements are allocated for rendering. |
| itemRenderer | TemplateRef | Rendering element template. |
| methodForSelecting | [MethodForSelecting](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/method-for-selecting.ts) | Method for selecting list items. Default value is 'none'. 'select' - List items are selected one by one. 'multi-select' - Multiple selection of list items. 'none' - List items are not selectable. |
| itemConfigMap | [IVirtualListItemConfigMap?](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/item-config-map.model.ts) | Sets `sticky` position and `selectable` for the list item element. If `sticky` position is greater than `0`, then `sticky` position is applied. If the `sticky` value is greater than `0`, then the `sticky` position mode is enabled for the element. `1` - position start, `2` - position end. Default value is `0`. `selectable` determines whether an element can be selected or not. Default value is `true`. |
| collapseByClick | boolean? = true | If `false`, the element is collapsed using the config.collapse method passed to the template; if `true`, the element is collapsed by clicking on it. The default value is `true`. |
| collectionMode | [CollectionMode? = 'normal'](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/collection-mode.ts) | Determines the action modes for collection elements. Default value is `normal`. |
| selectByClick | boolean? = true | If `false`, the element is selected using the config.select method passed to the template; if `true`, the element is selected by clicking on it. The default value is `true`. |
| snap | boolean? = false | Determines whether elements will snap. Default value is "false". |
| snappingMethod | [SnappingMethod? = 'normal'](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts) | Snapping method. 'normal' - Normal group rendering. 'advanced' - The group is rendered on a transparent background. List items below the group are not rendered. |
| direction | [Direction? = 'vertical'](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/direction.ts) | Determines the direction in which elements are placed. Default value is "vertical". |
| dynamicSize | boolean? = false | If true then the items in the list can have different sizes and the itemSize property is ignored. If false then the items in the list have a fixed size specified by the itemSize property. The default value is false. |
| enabledBufferOptimization | boolean? = true | Experimental! Enables buffer optimization. Can only be used if items in the collection are not added or updated. |
| trackBy | string? = 'id' | The name of the property by which tracking is performed. |
| selectedIds | Array<[Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts)> \| [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts) \| undefined | Sets the selected items. |
| collapsedIds | Array<[Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts)> | Sets the collapsed items. |
| screenReaderMessage | string? = "Showing items $1 to $2" | Message for screen reader. The message format is: "some text `$1` some text `$2`", where `$1` is the number of the first element of the screen collection, `$2` is the number of the last element of the screen collection. |
<br/>
Outputs
| Event | Type | Description |
|---|---|---|
| onItemClick | [IRenderVirtualListItem](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-item.model.ts) \| undefined | Fires when an element is clicked. |
| onScroll | ([IScrollEvent](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-event.model.ts)) => void | Fires when the list has been scrolled. |
| onScrollEnd | ([IScrollEvent](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-event.model.ts)) => void | Fires when the list has completed scrolling. |
| onSelect | Array<[Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts)> \| [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts) \| undefined | Fires when an elements are selected. |
| onCollapse | Array<[Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts)> \| [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts) \| undefined | Fires when elements are collapsed. |
| onViewportChange | [ISize](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/size.ts) | Fires when the viewport size is changed. |
| onScrollReachStart | void | Fires when the scroll reaches the start. |
| onScrollReachEnd | void | Fires when the scroll reaches the end. |
<br/>
Methods
| Method | Type | Description |
|--|--|--|
| scrollTo | (id: [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts), cb?: () => void, options?: [IScrollOptions](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-options.model.ts)) | The method scrolls the list to the element with the given `id` and returns the value of the scrolled area. |
| scrollToEnd | (cb?: () => void, options?: [IScrollOptions](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-options.model.ts)) | Scrolls the scroll area to the last item in the collection. |
| getItemBounds | (id: [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts), behavior?: ScrollBehavior) => void | Returns the bounds of an element with a given id |
| focus | [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts), align: [FocusAlignment](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/focus-alignment.ts) = [FocusAlignments.NONE](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/focus-alignments.ts) | Focus an list item by a given id. |
<br/>
### Template API
```html
<ng-template #itemRenderer let-data="data" let-config="config" let-measures="measures">
<!-- content -->
</ng-template>
```
Properties
| Property | Type | Description |
|--|--|--|
| data | {\[id: [Id](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/types/id.ts) \], [otherProps: string]: any;} | Collection item data. |
| config | [IDisplayObjectConfig](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/display-object-config.model.ts) | Display object configuration. A set of `select`, `collapse`, and `focus` methods are also provided. |
| measures | [IDisplayObjectMeasures](https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/display-object-measures.model.ts) \| undefined | Display object metrics. |
<br/>
## π¦ Previous versions
| Angular version | ng-virtual-list version | git | npm |
|--|--|--|--|
| 19.x | 19.7.29 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.7.29](https://www.npmjs.com/package/ng-virtual-list/v/19.7.29) |
| 18.x | 18.7.17 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.7.17](https://www.npmjs.com/package/ng-virtual-list/v/18.7.17) |
| 17.x | 17.7.18 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.7.18](https://www.npmjs.com/package/ng-virtual-list/v/17.7.18) |
| 16.x | 16.7.16 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.7.16](https://www.npmjs.com/package/ng-virtual-list/v/16.7.16) |
| 15.x | 15.7.16 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.7.16](https://www.npmjs.com/package/ng-virtual-list/v/15.7.16) |
| 14.x | 14.7.17 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.7.17](https://www.npmjs.com/package/ng-virtual-list/v/14.7.17) |
<br/>
## π€ Contributing
PRs and feature requests are welcome!
Open an issue or start a discussion to shape the future of [ng-virtual-list](https://github.com/DjonnyX/ng-virtual-list/).
Try it out, star β the repo, and let us know what youβre building.
<br/>
## π License
MIT License
Copyright (c) 2025 djonnyx (Evgenii Grebennikov)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.