Quick start
expo-modern-table has two parts:
ModernTable— the component. It is presentational: it renders what it’s given and reports user actions through callbacks.useTable— a hook that owns the state (search, sort, filters, page, selection, column layout) and hands it to the table throughgetTableProps().
Your first table
Section titled “Your first table”import { ModernTable, useTable, type Column } from 'expo-modern-table';
type Order = { id: string; customer: string; status: 'paid' | 'pending' | 'refunded'; total: number;};
// Define columns outside the component (or memoize them).const columns: Column<Order>[] = [ { key: 'id', title: 'Order', width: 100, isSticky: true }, { key: 'customer', title: 'Customer', width: 180 }, { key: 'status', title: 'Status', width: 120, filterConfig: { type: 'select', options: ['paid', 'pending', 'refunded'] }, }, { key: 'total', title: 'Total', width: 110, align: 'right', footer: 'sum' },];
export function OrdersTable({ orders }: { orders: Order[] }) { const table = useTable(orders, columns, 20); // 20 rows per page
return <ModernTable columns={columns} {...table.getTableProps()} />;}This already gives you:
- a search field in the toolbar (it searches every column),
- sorting by tapping a header (ascending → descending → off),
- a filter button on the Status header,
- a pinned Order column while the rest scrolls horizontally,
- checkbox selection, pagination with a page-size picker, a density toggle and a column menu to show, hide and pin columns,
- a summary row with the sum of
totalover every row matching the filters.
Rows need an identity
Section titled “Rows need an identity”Rows with an id field work out of the box. Otherwise pass getRowId — TypeScript requires it
when your row type has no id:
const getRowId = (row: Product) => row.sku; // stable function, outside the component
const table = useTable(products, columns, { pageSize: 20, getRowId });Customize cells
Section titled “Customize cells”renderCell returns any React Native element. Sorting, filters and search keep using the raw
value (or getValue when you set one):
{ key: 'status', title: 'Status', width: 120, renderCell: order => <StatusBadge status={order.status} />,},{ key: 'total', title: 'Total', width: 110, align: 'right', renderCell: order => <Text>{formatMoney(order.total)}</Text>,},Add features with props
Section titled “Add features with props”Most features are a prop away:
<ModernTable columns={columns} {...table.getTableProps()} theme="dark" enableColumnResize enableColumnReorder renderExpandedRow={order => <OrderDetails order={order} />} renderBulkActions={ids => <ExportButton ids={ids} />} onRowPress={order => navigation.navigate('Order', { id: order.id })}/>Next steps
Section titled “Next steps”- useTable — options, what the hook returns, controlled state.
- Server-side data — when your API sorts, filters and paginates.
- Columns — widths, pinning, resizing and custom headers.
- ModernTable props — the full list.