Datatable Example
Translate in French
1 - 50 / 500
0 selected
First name | lastName | Age | Visits | Status | Description | Profile Progress | ||
|---|---|---|---|---|---|---|---|---|
| Judith | Daugherty | 25 | 825 | single | 67 | |||
| Cecile | Kohler | 30 | 101 | complicated | 51 | |||
| Iris | Larson | 2 | 46 | single | 88 | |||
| Manuel | Brekke | 13 | 595 | complicated | 4 | |||
| Jasper | Ankunding | 14 | 169 | relationship | 88 | |||
| Antonette | Hilpert | 0 | 394 | relationship | 87 | |||
| Rosalie | Grimes | 32 | 679 | single | 81 | |||
| Marcella | Quitzon | 38 | 912 | relationship | 57 | |||
| Alonzo | Funk | 31 | 629 | relationship | 73 | |||
| Meggie | Schaefer | 22 | 955 | relationship | 10 | |||
| Julius | Kertzmann | 5 | 635 | relationship | 100 | |||
| Kylee | Lowe | 33 | 977 | relationship | 39 | |||
| Stephanie | Bailey | 12 | 736 | complicated | 84 | |||
| Rebecca | Dach | 15 | 254 | complicated | 69 | |||
| Yvette | Doyle | 14 | 561 | single | 56 | |||
| Arch | Frami | 14 | 679 | complicated | 54 | |||
| Ruthie | Shields | 25 | 4 | complicated | 92 | |||
| Davin | Jacobi | 22 | 796 | single | 80 | |||
| Lue | Homenick | 20 | 115 | complicated | 22 | |||
| Rudolph | Schowalter | 17 | 471 | relationship | 9 | |||
| Joyce | Pollich | 6 | 156 | single | 94 | |||
| Jean | Schmeler | 8 | 491 | single | 79 | |||
| Tamia | Beier | 39 | 680 | relationship | 88 | |||
| May | Abshire | 11 | 51 | single | 42 | |||
| Hertha | Reinger | 13 | 480 | complicated | 8 | |||
| Rhianna | Beer | 30 | 352 | single | 4 | |||
| Judy | Rath | 25 | 695 | relationship | 74 | |||
| Rufus | Upton | 24 | 830 | single | 5 | |||
| Karson | Gottlieb | 34 | 83 | relationship | 74 | |||
| Jerald | Spencer | 5 | 194 | single | 70 | |||
| Korey | Powlowski | 8 | 959 | complicated | 56 | |||
| Alf | Mohr | 24 | 215 | single | 28 | |||
| Elvira | Kiehn | 0 | 546 | single | 25 | |||
| Melanie | Ullrich | 4 | 65 | complicated | 80 | |||
| Micheal | Konopelski | 28 | 48 | complicated | 5 | |||
| Deonte | Labadie | 15 | 828 | complicated | 69 | |||
| Darnell | Ullrich | 27 | 347 | relationship | 51 | |||
| Theresa | Lind-Wisoky | 8 | 131 | complicated | 12 | |||
| Zakary | Kuhic | 39 | 552 | relationship | 19 | |||
| Trevor | Schinner | 5 | 442 | complicated | 83 | |||
| Jayde | Lemke | 18 | 842 | complicated | 85 | |||
| Kayleigh | Hills | 27 | 325 | complicated | 60 | |||
| Darien | Huel | 29 | 620 | relationship | 85 | |||
| Travis | Emmerich | 3 | 182 | single | 24 | |||
| Domenica | Hartmann-Reichert | 18 | 903 | relationship | 72 | |||
| Latoya | Pfannerstill | 35 | 292 | complicated | 87 | |||
| Elmore | Paucek | 39 | 805 | single | 59 | |||
| Viola | Kutch | 27 | 561 | relationship | 99 | |||
| Oceane | Mitchell | 26 | 88 | single | 72 | |||
| Ladarius | Wehner | 22 | 127 | single | 62 |
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 />