Datatable Example
Translate in French
1 - 50 / 500
0 selected
First name | lastName | Age | Visits | Status | Description | Profile Progress | ||
|---|---|---|---|---|---|---|---|---|
| Katrina | Harris-Cartwright | 4 | 444 | single | 0 | |||
| Iva | Steuber | 37 | 354 | relationship | 60 | |||
| Cleveland | Towne | 40 | 205 | relationship | 96 | |||
| Demond | Trantow | 21 | 906 | relationship | 78 | |||
| Dillon | Pagac | 29 | 870 | relationship | 55 | |||
| Brock | Ondricka | 10 | 334 | relationship | 38 | |||
| Mark | Welch | 6 | 461 | complicated | 78 | |||
| Mavis | Reilly | 8 | 742 | single | 30 | |||
| Cynthia | Ferry | 37 | 322 | relationship | 21 | |||
| Gilberto | Bins | 32 | 1000 | single | 13 | |||
| Ernestine | Hartmann | 17 | 945 | complicated | 4 | |||
| Brando | Schulist | 2 | 867 | complicated | 87 | |||
| Skyla | Turner | 40 | 539 | single | 35 | |||
| Shaun | Leuschke-Walsh | 20 | 413 | complicated | 65 | |||
| Felipe | Sipes | 32 | 512 | relationship | 68 | |||
| Cassandra | Batz | 10 | 935 | relationship | 11 | |||
| Duncan | Gottlieb | 8 | 729 | relationship | 91 | |||
| Darla | McClure | 20 | 312 | relationship | 48 | |||
| Kristopher | Hoppe | 18 | 722 | relationship | 6 | |||
| Kara | Thompson | 3 | 886 | single | 54 | |||
| Demond | White-Skiles | 20 | 136 | relationship | 31 | |||
| Bonita | Larkin | 17 | 689 | relationship | 99 | |||
| Aimee | Simonis | 32 | 319 | relationship | 50 | |||
| Dwayne | Hayes | 21 | 128 | complicated | 24 | |||
| Emmy | Quigley | 8 | 430 | complicated | 98 | |||
| Carla | Metz | 12 | 346 | complicated | 25 | |||
| Toby | Hills | 30 | 262 | relationship | 42 | |||
| Brady | Hickle | 20 | 15 | single | 81 | |||
| Kameron | Durgan | 37 | 80 | single | 30 | |||
| Carmen | Ortiz | 39 | 240 | single | 84 | |||
| Ruben | Wuckert | 20 | 69 | complicated | 98 | |||
| Roma | Koelpin | 20 | 534 | complicated | 34 | |||
| Selmer | Dietrich | 26 | 322 | single | 52 | |||
| Thomas | Schinner | 32 | 101 | relationship | 55 | |||
| Sue | Lakin | 36 | 727 | single | 52 | |||
| Geovanny | Fahey | 15 | 497 | relationship | 15 | |||
| Santos | Schoen | 10 | 610 | single | 76 | |||
| Kelsie | Rolfson | 26 | 828 | complicated | 27 | |||
| Verna | Bartell-Welch | 39 | 938 | relationship | 59 | |||
| Walton | Sawayn | 33 | 864 | relationship | 52 | |||
| Carmella | Romaguera | 17 | 90 | single | 47 | |||
| Emmalee | Beahan | 9 | 312 | relationship | 63 | |||
| Rollin | Orn | 31 | 784 | complicated | 72 | |||
| Heather | Dach | 20 | 680 | complicated | 75 | |||
| Sandra | Greenfelder | 36 | 550 | relationship | 37 | |||
| Saul | Hilll | 13 | 309 | complicated | 31 | |||
| Frederick | Flatley | 34 | 726 | relationship | 25 | |||
| Aaron | Kshlerin | 29 | 378 | complicated | 82 | |||
| Antonietta | Langworth | 10 | 627 | relationship | 38 | |||
| Rosa | Grimes | 18 | 787 | single | 54 |
Selected
{
"selectAll": false,
"selectedIds": [],
"excludedIds": []
}How to use this separator
Props
| Name | Type | Default | Description |
|---|---|---|---|
| data | MyCustomType[] | - | The data displayed in the tab. |
| columns | <ColumnDef<MyCustomType>[]> | - | The name of the colomns, how to get it, actions on column... |
| isLoading | boolean | - | Displays a skeleton on rows while loading. |
| tableOptions | {onRowSelectionChange, getSortedRowModel, getPaginationRowModel, onPaginationChange, enableRowSelection, onColumnOrderChange } | - | Change the default rendered element for the one passed as a child, merging their props and behavior. |
| tableState | {columnVisibility, columnOrder: string[], columnPinning:{left: string[], right: string[] }, rowPinning{bottom: string[], top: string[] }, columnFilters: {id: string, value: unknown }[], globalFilter: any, sorting: {desc: boolean, id: string }[], expanded:?, grouping: string[], columnSizing:?, columnSizingInfo: { columnSizingStart: [string, number][], deltaOffset: null | number,deltaPercentage: null | number,isResizingColumn: false | string, startOffset: null | number, startSize: null | number } } | - | Change the default rendered element for the one passed as a child, merging their props and behavior. |
| onClickRow | (row: Row<TData>) => void | - | Action function triggered when the user clicks on a row. |
| onResetTable | () => void | - | Reset localStorage used for preferences (order table, number of rows...). |
| toolbar | ReactNode | - | Put anything in this toolbar : button, text, select... |
| selection | { createSelectionColumn?: boolean, totalSelectableCount?: number,selectionState?: {state, onSelectionChange}, handlers?: {isRowSelected?,toggleRow?,toggleSelectAll?,getSelectionCount?,clearSelection?,isAllSelected?,isSomeSelected?},selectionHeader?: {custom?: (props: {selectionState: SelectionState}) => ReactNode, actions?: (props: {selectionState: SelectionState}) => ReactNode} } | - | Activate and changes the default display or behavior of the table selection |
Playground
Import from @filigran/ui :
Import {Separator} from '@filigran/ui'
Everything possible for declaring columns :
const columns = useMemo<ColumnDef<Person>[]>( () => [ { id: 'select', size: 20, header: ({table}) => ( <Checkbox className="flex" checked={ table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && 'indeterminate') } onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value) } aria-label="Select all" /> ), cell: ({row}) => ( <Checkbox className="flex" checked={row.getIsSelected()} onClick={(e) => e.stopPropagation()} onCheckedChange={(value) => { row.toggleSelected(!!value) }} aria-label="Select row" /> ), enableSorting: false, enableHiding: false, enableResizing: false }, { id: 'firstName', accessorKey: 'firstName', enableHiding: true, enableSorting: false, cell: (info) => ( <HighlightSearchTerm text={info.getValue() as string} /> ), header: 'First name' }, { accessorFn: (row) => row.lastName, id: 'lastName', enableHiding: false, cell: (info) => ( <HighlightSearchTerm text={info.getValue() as string} /> ), header: (header) => ( <DataTableOptionsHeader column={header.column} title={'Last name'} menuItems={ <> <DropdownMenuItem onClick={() => console.log(header.column)}> Log column </DropdownMenuItem> <DropdownMenuItem onClick={() => console.log(header.column)}> Log column 2 </DropdownMenuItem> </> } /> ) }, { id: 'age', accessorKey: 'age', header: 'Age' }], [])
<DataTable data={data} columns={columns} isLoading={loading} i18nKey={isCheckedI18n ? frenchI18nKey : {}} tableOptions={{ onRowSelectionChange: setRowSelection, getSortedRowModel: getSortedRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, enableRowSelection: (row) => row.original.age > 18, //only enable row selection for adults onColumnOrderChange: setColumnOrder }} tableState={{ rowSelection, pagination, columnOrder, columnPinning: { left: ['select'] } //Force left column on the left, can not be pinned. }} selection={{ createDefaultSelectionColumn: true, totalSelectableCount: totalSelectable, defaultSelectionHeaderActions: ({ selectionState }) => ( <> <Button variant="ghost-destructive" size="icon" className="border" onClick={() => console.log(selectionState)}> <Trash className="size-4" /> </Button> </> ), }} onClickRow={(row) => console.log(row)} // Action on click />