List
列表

最基础的列表展示,可承载文字、列表、图片、段落。
使用import{ List }from"antd";

何时使用

最基础的列表展示,可承载文字、列表、图片、段落,常用于后台数据展示页面。

代码演示

Header
  • [ITEM] Racing car sprays burning fuel into crowd.
  • [ITEM] Japanese princess to wed commoner.
  • [ITEM] Australian walks 100km after outback crash.
  • [ITEM] Man charged over missing wedding girl.
  • [ITEM] Los Angeles battles huge wildfires.
Header
  • Racing car sprays burning fuel into crowd.
  • Japanese princess to wed commoner.
  • Australian walks 100km after outback crash.
  • Man charged over missing wedding girl.
  • Los Angeles battles huge wildfires.
Header
  • Racing car sprays burning fuel into crowd.
  • Japanese princess to wed commoner.
  • Australian walks 100km after outback crash.
  • Man charged over missing wedding girl.
  • Los Angeles battles huge wildfires.

列表拥有大、中、小三种尺寸。

通过设置 sizelarge small 分别把按钮设为大、小尺寸。若不设置 size,则尺寸为中。

可通过设置 headerfooter,来自定义列表头部和尾部。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
  • Ant Design Title 1

    Ant Design, a design language for background applications, is refined by Ant UED Team
  • Ant Design Title 2

    Ant Design, a design language for background applications, is refined by Ant UED Team
  • Ant Design Title 3

    Ant Design, a design language for background applications, is refined by Ant UED Team
  • Ant Design Title 4

    Ant Design, a design language for background applications, is refined by Ant UED Team

基础列表。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

可通过 loadMore 属性实现加载更多功能。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
  • ant design part 0

    Ant Design, a design language for background applications, is refined by Ant UED Team.
    We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
    • 156
    • 156
    • 2
    logo
  • ant design part 1

    Ant Design, a design language for background applications, is refined by Ant UED Team.
    We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
    • 156
    • 156
    • 2
    logo
  • ant design part 2

    Ant Design, a design language for background applications, is refined by Ant UED Team.
    We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
    • 156
    • 156
    • 2
    logo

通过设置 itemLayout 属性为 vertical 可实现竖排列表样式。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Pagination Position:
Pagination Align:
  • Ant Design Title 1

    Ant Design, a design language for background applications, is refined by Ant UED Team
  • Ant Design Title 2

    Ant Design, a design language for background applications, is refined by Ant UED Team
  • Ant Design Title 3

    Ant Design, a design language for background applications, is refined by Ant UED Team
  • Ant Design Title 4

    Ant Design, a design language for background applications, is refined by Ant UED Team

可通过 pagination 属性使用列表分页,并进行设置。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Title 1
Card content
Title 2
Card content
Title 3
Card content
Title 4
Card content

可以通过设置 Listgrid 属性来实现栅格列表,column 可设置期望显示的列数。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Title 1
Card content
Title 2
Card content
Title 3
Card content
Title 4
Card content
Title 5
Card content
Title 6
Card content

响应式的栅格列表。尺寸与 Layout Grid 保持一致。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
暂无数据
暂无数据

结合 react-infinite-scroll-component 实现滚动自动加载列表。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

结合 rc-virtual-list 实现滚动加载无限长列表,能够提高数据量大时候长列表的性能。

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

API

通用属性参考:通用属性

另外我们封装了 ProList,在 antd List 之上扩展了更多便捷易用的功能,比如多选,展开等功能,使用体验贴近 Table,欢迎尝试使用。

List

参数说明类型默认值版本
bordered是否展示边框booleanfalse
dataSource列表数据源any[]-
footer列表底部ReactNode-
grid列表栅格配置object-
header列表头部ReactNode-
itemLayout设置 List.Item 布局,设置成 vertical 则竖直样式显示,默认横排string-
loading当卡片内容还在加载中时,可以用 loading 展示一个占位boolean | object (更多)false
loadMore加载更多ReactNode-
locale默认文案设置,目前包括空数据文案object{emptyText: 暂无数据}
pagination对应的 pagination 配置,设置 false 不显示boolean | objectfalse
renderItem当使用 dataSource 时,可以用 renderItem 自定义渲染列表项(item) => ReactNode-
rowKeyrenderItem 自定义渲染列表项有效时,自定义每一行的 key 的获取方式keyof T | (item: T) => React.Key"key"
sizelist 的尺寸default | large | smalldefault
split是否展示分割线booleantrue

pagination

分页的配置项。

参数说明类型默认值
position指定分页显示的位置top | bottom | bothbottom
align指定分页对齐的位置start | center | endend

更多配置项,请查看 Pagination

List grid props

参数说明类型默认值版本
column列数number-
gutter栅格间隔number0
xs<576px 展示的列数number-
sm≥576px 展示的列数number-
md≥768px 展示的列数number-
lg≥992px 展示的列数number-
xl≥1200px 展示的列数number-
xxl≥1600px 展示的列数number-

List.Item

参数说明类型默认值版本
actions列表操作组,根据 itemLayout 的不同,位置在卡片底部或者最右侧Array<ReactNode>-
classNames语义化结构 classNameRecord<actions | extra, string>-5.18.0
extra额外内容,通常用在 itemLayoutvertical 的情况下,展示右侧内容; horizontal 展示在列表元素最右侧ReactNode-
styles语义化结构 styleRecord<actions | extra, CSSProperties>-5.18.0

List.Item.Meta

参数说明类型默认值版本
avatar列表元素的图标ReactNode-
description列表元素的描述内容ReactNode-
title列表元素的标题ReactNode-

Semantic DOM

  • ant design part 0

    Ant Design, a design language for background applications, is refined by Ant UED Team.
    We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.
    • 156
    • 156
    • 2
    logo
  • extra
    5.18.0
    设置额外内容
  • actions
    5.18.0
    设置列表操作组

主题变量(Design Token)

组件 Token如何定制?

Token 名称描述类型默认值
avatarMarginRight头像右间距undefined | MarginRight<string | number>16
contentWidth内容宽度string | number220
descriptionFontSize描述文字大小number14
emptyTextPadding空文本内边距undefined | Padding<string | number>16
footerBg底部区域背景色stringtransparent
headerBg头部区域背景色stringtransparent
itemPadding列表项内间距string12px 0
itemPaddingLG大号列表项内间距string16px 24px
itemPaddingSM小号列表项内间距string8px 16px
metaMarginBottomMeta 下间距undefined | MarginBottom<string | number>16
titleMarginBottom标题下间距undefined | MarginBottom<string | number>12

全局 Token如何定制?