Datatable Example
Translate in French
1 - 50 / 500
0 selected
First name | lastName | Age | Visits | Status | Description | Profile Progress | ||
|---|---|---|---|---|---|---|---|---|
| Camilla | Kunde | 10 | 67 | complicated | 48 | |||
| Kent | Fay | 19 | 630 | single | 25 | |||
| Imelda | Von | 23 | 294 | complicated | 69 | |||
| Stanley | Schaefer | 21 | 833 | relationship | 46 | |||
| Chris | Nikolaus | 4 | 532 | relationship | 90 | |||
| Consuelo | Mante | 36 | 806 | complicated | 36 | |||
| Ken | Boyle | 33 | 258 | complicated | 40 | |||
| Jimmy | Koch | 10 | 839 | relationship | 31 | |||
| Eugene | Wilderman | 35 | 815 | single | 91 | |||
| Mertie | Dibbert-Kilback | 36 | 970 | relationship | 44 | |||
| Kirsten | Block | 31 | 504 | relationship | 18 | |||
| Felicia | Hettinger | 2 | 842 | complicated | 40 | |||
| Patsy | Christiansen | 6 | 399 | single | 10 | |||
| Stephen | Wehner | 15 | 161 | complicated | 85 | |||
| Kay | Crooks | 12 | 436 | single | 28 | |||
| Phoebe | Marks | 25 | 350 | complicated | 29 | |||
| Amos | Herzog | 13 | 159 | relationship | 76 | |||
| Antone | Thiel | 4 | 587 | relationship | 19 | |||
| Bertha | Dietrich | 11 | 93 | single | 20 | |||
| Henrietta | Weimann | 3 | 204 | complicated | 76 | |||
| Ed | Leuschke | 10 | 581 | relationship | 27 | |||
| Carolyn | Hartmann | 25 | 12 | single | 83 | |||
| Lula | Keebler | 15 | 387 | single | 90 | |||
| Erich | Pfannerstill | 0 | 406 | single | 97 | |||
| Neil | Goodwin | 39 | 177 | relationship | 44 | |||
| Neoma | Hermann | 40 | 634 | single | 99 | |||
| Carlotta | Bechtelar | 2 | 672 | relationship | 40 | |||
| Maryjane | Fay | 21 | 670 | single | 86 | |||
| Tanya | Balistreri | 4 | 348 | relationship | 69 | |||
| Josefa | Reynolds | 5 | 612 | single | 99 | |||
| Rachelle | Keeling | 26 | 851 | complicated | 2 | |||
| Percy | Cormier | 39 | 142 | complicated | 40 | |||
| Beulah | Windler | 36 | 980 | relationship | 23 | |||
| Dasia | Stamm | 21 | 482 | complicated | 68 | |||
| Loyal | Gerlach | 11 | 356 | complicated | 33 | |||
| Wilbur | Morissette | 22 | 58 | relationship | 65 | |||
| Cale | Cruickshank | 33 | 229 | complicated | 94 | |||
| Coy | Littel | 12 | 995 | single | 84 | |||
| Lorenzo | Jakubowski | 36 | 887 | single | 24 | |||
| Sergio | Pfannerstill | 25 | 767 | relationship | 27 | |||
| Anna | Rohan | 40 | 267 | relationship | 75 | |||
| Gabriel | Hyatt | 19 | 250 | relationship | 31 | |||
| Carli | Hahn | 0 | 847 | single | 44 | |||
| Kareem | Daugherty | 23 | 873 | complicated | 35 | |||
| Glenn | Kris | 18 | 886 | complicated | 39 | |||
| Theodora | Hyatt | 2 | 78 | complicated | 3 | |||
| Destiny | Kunde | 0 | 79 | complicated | 89 | |||
| Van | Wolff | 19 | 459 | complicated | 19 | |||
| Penelope | Schultz | 33 | 544 | relationship | 24 | |||
| Tasha | Emmerich | 22 | 544 | single | 36 |
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 />