Columns
A ColumnDef describes one column: which field it reads, how wide it is, and how its values behave.
Basic usage
columns.tsx
import { DataGrid, type ColumnDef } from 'expo-flash-datagrid';
import { users, type User } from './data';
const columns: ColumnDef<User>[] = [
{ field: 'name', headerName: 'Name', flex: 2, minWidth: 180 },
{ field: 'email', headerName: 'Email', flex: 1, minWidth: 200 },
{
field: 'age',
headerName: 'Age',
type: 'number',
width: 90,
align: 'right',
headerAlign: 'right',
},
{
field: 'registeredAt',
headerName: 'Registered',
type: 'date',
width: 130,
},
{ field: 'active', headerName: 'Active', type: 'boolean', width: 90 },
];
export function ColumnsScreen() {
return (
<DataGrid<User>
mode="client"
rows={users}
columns={columns}
style={{ flex: 1 }}
/>
);
}
Options
| Field | Type | Default | Description |
|---|---|---|---|
field | string | Required | Key read from the row, and the column's identity. |
headerName | string | Required | Header label. |
type | ColumnType | 'string' | Sets default sorting, filter operators, and input. |
width | number | 140 | Fixed width in pixels. |
minWidth | number | 96 | Lower bound for width and flex. |
flex | number | None | Share of the width left after fixed columns. Overrides width. |
align | 'left' | 'center' | 'right' | None | Cell alignment. |
headerAlign | 'left' | 'center' | 'right' | None | Header alignment. |
Column types are 'string', 'number', 'date', 'datetime', 'boolean', 'actions', and 'custom'.
When the columns are wider than the grid, the table scrolls horizontally.
Client vs server
Column layout is always handled by the grid. In server mode, type still determines which filter operators appear, but your API has to apply them.