Skip to content

List

Display a list of items with support for pagination and loading states.

import { List } from 'asterui'

Basic List

Simple list with items.

  • Racing car sprints past
  • Japanese princess unveiled
  • Australian walks 100km
  • Man charged over missing wedding
import { List } from 'asterui'

function App() {
  const basicData = [
    'Racing car sprints past',
    'Japanese princess unveiled',
    'Australian walks 100km',
    'Man charged over missing wedding',
  ];
  
  return (
      <List
        dataSource={basicData}
        renderItem={(item) => <List.Item>{item}</List.Item>}
      />
    )
}

export default App

With Avatar

List items with avatars and descriptions.

  • Alice Johnson
    Alice Johnson
    alice@example.com
  • Bob Smith
    Bob Smith
    bob@example.com
  • Carol White
    Carol White
    carol@example.com
import { List, Avatar } from 'asterui'

function App() {
  const avatarData = [
    {
      name: 'Alice Johnson',
      email: 'alice@example.com',
      avatar: 'https://i.pravatar.cc/150?img=5',
    },
    {
      name: 'Bob Smith',
      email: 'bob@example.com',
      avatar: 'https://i.pravatar.cc/150?img=12',
    },
    {
      name: 'Carol White',
      email: 'carol@example.com',
      avatar: 'https://i.pravatar.cc/150?img=9',
    },
  ];
  
  return (
      <List
        dataSource={avatarData}
        renderItem={(item) => (
          <List.Item>
            <List.Item.Meta
              avatar={<Avatar src={item.avatar} alt={item.name} />}
              title={item.name}
              description={item.email}
            />
          </List.Item>
        )}
      />
    )
}

export default App

Loading State

List in loading state with skeleton.

    Loading
import { List } from 'asterui'

function App() {
  return (
      <List
        dataSource={[]}
        renderItem={(item) => <List.Item>{item}</List.Item>}
        loading
      />
    )
}

export default App

With Pagination

List with pagination controls.

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
import { List } from 'asterui'
import { useState } from 'react'

function App() {
  const allData = Array.from({ length: 23 }, (_, i) => `Item ${i + 1}`);
  const [page, setPage] = useState(1);
  const pageSize = 5;
  const start = (page - 1) * pageSize;
  const end = start + pageSize;
  const currentData = allData.slice(start, end);
  
  return (
      <List
        dataSource={currentData}
        renderItem={(item) => <List.Item>{item}</List.Item>}
        pagination={{
          current: page,
          pageSize,
          total: allData.length,
          onChange: setPage,
        }}
      />
    )
}

export default App
PropertyDescriptionTypeDefault
dataSourceArray of data items to renderT[]-
renderItemFunction to render each item(item: T, index: number) => React.ReactNode-
headerList header contentReact.ReactNode-
footerList footer contentReact.ReactNode-
loadingWhether the list is in loading statebooleanfalse
paginationPagination configurationListPaginationConfig | falsefalse
gridGrid layout configurationListGridConfig-
borderedShow border around listbooleantrue
splitShow divider between itemsbooleantrue
sizeSize variant'sm' | 'md' | 'lg''md'
itemLayoutLayout direction for items'horizontal' | 'vertical''horizontal'
localeInternationalization text{ emptyText?: React.ReactNode }-
loadMoreLoad more content (e.g., button)React.ReactNode-
rowKeyCustom key extraction for itemskeyof T | ((item: T) => React.Key)-
data-testidTest ID for the componentstring'list'
aria-labelAccessible label for the liststring-
PropertyDescriptionTypeDefault
childrenItem contentReact.ReactNode-
actionsAction buttons displayed on the rightReact.ReactNode[]-
extraExtra content on the right sideReact.ReactNode-
classNameAdditional CSS classesstring-
PropertyDescriptionTypeDefault
avatarAvatar or icon elementReact.ReactNode-
titleTitle contentReact.ReactNode-
descriptionDescription contentReact.ReactNode-
  • Use aria-label to provide context for the list
  • List items are rendered in semantic <ul> or <ol> elements
  • Loading state is communicated to screen readers
  • Pagination controls are keyboard accessible
  • Empty state content is properly announced