@@ -12,7 +12,12 @@ import {
1212 useReactTable ,
1313} from '@tanstack/react-table' ;
1414import { useVirtualizer } from '@tanstack/react-virtual' ;
15- import type { CSSProperties , RefObject , TableHTMLAttributes } from 'react' ;
15+ import type {
16+ CSSProperties ,
17+ ReactNode ,
18+ RefObject ,
19+ TableHTMLAttributes ,
20+ } from 'react' ;
1621import { useEffect , useMemo , useRef } from 'react' ;
1722import { match } from 'ts-pattern' ;
1823
@@ -185,6 +190,18 @@ interface TableBaseProps<TData extends RowData> {
185190 * Ignored when using custom row rendering with `renderRowTr`.
186191 */
187192 renderRowPreview ?: TableRowPreviewRenderer < TData > ;
193+
194+ /**
195+ * Icon to display when the table is empty.
196+ * @default `<Icon icon="eye-off" />`
197+ */
198+ emptyIcon ?: ReactNode ;
199+
200+ /**
201+ * Content to display when the table is empty.
202+ * @default `'No data'`
203+ */
204+ emptyContent ?: ReactNode ;
188205}
189206
190207interface RegularTableProps <
@@ -244,6 +261,9 @@ export function Table<TData extends RowData>(props: TableProps<TData>) {
244261 renderRowPreview,
245262
246263 scrollToRowRef,
264+
265+ emptyIcon,
266+ emptyContent,
247267 } = props ;
248268 const isReorderingEnabled = ! ! onRowOrderChanged ;
249269 const virtualScrollElementRef = useRef < HTMLDivElement > ( null ) ;
@@ -294,13 +314,16 @@ export function Table<TData extends RowData>(props: TableProps<TData>) {
294314 } ) ,
295315 [ className , getTdProps , renderRowTr , columns , compact ] ,
296316 ) ;
317+
318+ const rows = table . getRowModel ( ) . rows ;
319+
297320 return (
298321 < FlashedRowProvider >
299322 < PreviewTablePropsContextProvider
300323 value = { tablePreviewProps as PreviewTablePropsContextValue < unknown > }
301324 >
302325 < ItemOrderProvider
303- items = { table . getRowModel ( ) . rows }
326+ items = { rows }
304327 onOrderChanged = { ( items ) => {
305328 onRowOrderChanged ?.( items . map ( ( item ) => item . original ) ) ;
306329 } }
@@ -341,14 +364,17 @@ export function Table<TData extends RowData>(props: TableProps<TData>) {
341364 />
342365 ) }
343366 < TableBody
344- rows = { table . getRowModel ( ) . rows }
367+ rows = { rows }
345368 renderRowTr = { renderRowTr }
346369 tdStyle = { tdStyle }
347370 getTdProps = { getTdProps }
348371 virtualizer = { tanstackVirtualizer }
349372 virtualizeRows = { virtualizeRows }
350373 renderRowPreview = { renderRowPreview }
351374 isReorderingEnabled = { isReorderingEnabled }
375+ emptyIcon = { emptyIcon }
376+ emptyContent = { emptyContent }
377+ columns = { table . getAllColumns ( ) . length }
352378 />
353379 </ CustomHTMLTable >
354380 </ ScrollContainer >
0 commit comments