JGuang

Listy

Listy · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Listy

A high-performance list that supports grouping and can virtualize long data sets.

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

  • Basic · basic
  • Virtual scrolling · virtual
  • Grouping and sticky headers · group
  • Rich content · rich
  • Drag sorting · drag-sorting
  • Infinite loading · infinite
  • Custom semantic dom styling · style-class

API

Listy component is available since antd@6.6.0.

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

Semantic nodeNative descriptionVersion
rootRoot element, the scroll container, with font and relative positioning—
itemItem element, with padding, split line and hover background—
groupHeaderGroup header element, with sticky positioning and background color—

Semantic description source: vendor/components/listy/demo/_semantic.tsx

Design Token

Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.

TokenTypeNative description
itemPaddingBlocknumberVertical padding of a list item.
itemPaddingInlinenumberHorizontal padding of a list item.

Declaration source: vendor/components/listy/style/index.ts

import { unit } from '@ant-design/cssinjs';

import type { CSSObject } from '@ant-design/cssinjs';

import { resetComponent } from '../../style';

import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks } from '../../theme/internal';

export interface ComponentToken {
  /**
   * @nameZH 列表项纵向内间距
   * @nameEN Item Vertical Padding
   * @desc 列表项的纵向内间距。
   * @descEN Vertical padding of a list item.
   */
  itemPaddingBlock: number;
  /**
   * @nameZH 列表项横向内间距
   * @nameEN Item Horizontal Padding
   * @desc 列表项的横向内间距。
   * @descEN Horizontal padding of a list item.
   */
  itemPaddingInline: number;
}

type ListyToken = FullToken<'Listy'>;

Shared native props

Tips: The following generic properties apply to most antd components; those not supported are described separately.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

Install and reproduce an example

npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.

Native type references

The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.

  • vendor/components/listy/index.tsx
  • vendor/components/listy/style/index.ts

Source and license

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.