Skip to main content

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​

FieldTypeDefaultDescription
fieldstringRequiredKey read from the row, and the column's identity.
headerNamestringRequiredHeader label.
typeColumnType'string'Sets default sorting, filter operators, and input.
widthnumber140Fixed width in pixels.
minWidthnumber96Lower bound for width and flex.
flexnumberNoneShare of the width left after fixed columns. Overrides width.
align'left' | 'center' | 'right'NoneCell alignment.
headerAlign'left' | 'center' | 'right'NoneHeader 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.