List

List, a React Native component for iOS, Android and web: A virtualized list with empty and loading states, plus ListItem.

Usage

import { Badge } from './components/ui/badge';
import { List, ListItem } from './components/ui/list';

const ORDERS = [
  { id: '1', title: 'Copper Handi', detail: 'North Indian', state: 'On the way' },
  { id: '2', title: 'Slice Theory', detail: 'Wood-fired pizza', state: 'Delivered' },
  { id: '3', title: 'Noodle Foundry', detail: 'Hand-pulled noodles', state: 'Delivered' },
];

export default function Example() {
  return (
    <List
      data={ORDERS}
      dividers
      keyExtractor={(order) => order.id}
      renderItem={({ item }) => <ListItem title={item.title} description={item.detail} end={<Badge>{item.state}</Badge>} onPress={() => {}} />}
      style={{ maxWidth: 420 }}
    />
  );
}

Props

PropTypeDefaultDescription
loadingbooleanfalseShown instead of rows while the first page loads.
emptyTextstring'Nothing here yet'Shown when `data` is empty and not loading.
emptyReactNodeReplaces the default empty text.
dividersbooleantrueDraw a divider between rows.
titlestring
descriptionstring
startReactNodeIcon or avatar, on the leading side.
endReactNodeValue or control, on the trailing side.
onPress() => voidMakes the row a button.
disabledboolean
selectedboolean
styleStyleProp<ViewStyle>
testIDstring