Back to Ant Design

Listy

components/listy/index.en-US.md

6.6.03.3 KB
Original Source

When To Use

  • When you need to render a long list without paying the cost of mounting every row — enable virtual to render only the rows in view.
  • When the list needs grouped sections with sticky headers.
  • When you need imperative control over scroll position (jump to an item, a group, or a pixel offset).

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/virtual.tsx">Virtual scrolling</code> <code src="./demo/group.tsx">Grouping and sticky headers</code> <code src="./demo/rich.tsx">Rich content</code> <code src="./demo/infinite.tsx">Infinite loading</code> <code src="./demo/style-class.tsx">Custom semantic dom styling</code> <code src="./demo/scroll-to.tsx" debug>Scroll control</code>

API

Listy component is available since [email protected].

Common props ref: Common props

PropertyDescriptionTypeDefaultVersionGlobal Config
classNamesSemantic class names{ root?, item?, groupHeader? }-6.6.06.6.0
groupGrouping config, see Group belowGroup<T, K>-6.6.0×
heightHeight of the scroll container; content scrolls when it overflowsnumber-6.6.0×
itemRenderRender a single row(item: T, index: number) => ReactNode-6.6.0×
itemsData source of the listT[][]6.6.0×
rowKeyUnique key of an item, a field name or a getterkeyof T | (item: T) => Key-6.6.0×
stickyWhether group headers stick to the topbooleanfalse6.6.0×
stylesSemantic inline styles{ root?, item?, groupHeader? }-6.6.06.6.0
virtualWhether to enable virtual scrolling, rendering only rows in view, requires heightbooleanfalse6.6.0×
onScrollNative scroll event handlerReact.UIEventHandler<HTMLElement>-6.6.0×

Group

PropertyDescriptionType
keyCompute the group key an item belongs to; items with the same key are grouped together(item: T) => K
titleRender the group header; receives the group key and its items(groupKey: K, items: T[]) => ReactNode

Ref

NameDescriptionType
scrollToScroll to a position, an item, or a group(config?: ListyScrollToConfig) => void

ListyScrollToConfig is one of:

ShapeDescription
numberScroll to a pixel offset (scrollTop)
{ top?, left? }Scroll to an absolute pixel position
{ key, align?, offset? }Scroll to the item whose rowKey matches key
{ groupKey, align?, offset? }Scroll to a group header

align is 'top' | 'bottom' | 'auto'; offset is an extra pixel offset applied after alignment.

Semantic DOM

<code src="./demo/_semantic.tsx" simplify="true"></code>

Design Token

<ComponentTokenTable component="Listy"></ComponentTokenTable>