Examples › Infinite scrolling
Scroll the table to the bottom to see it in action:
First name | Last name | Email |
|---|---|---|
| Jerald | Howell | Jerald.Howell32@yahoo.com |
| Kathleen | Ruecker | Kathleen_Ruecker@hotmail.com |
| Erica | Volkman | Erica.Volkman37@gmail.com |
| Clifford | Oberbrunner | Clifford.Oberbrunner@hotmail.com |
| Alison | Kling | Alison16@gmail.com |
| Sue | Zieme | Sue.Zieme29@hotmail.com |
| Felicia | Gleason | Felicia30@yahoo.com |
| Alfredo | Zemlak | Alfredo22@yahoo.com |
| Emily | Bartoletti | Emily.Bartoletti@gmail.com |
| Delores | Reynolds | Delores.Reynolds@yahoo.com |
| Louis | Schamberger | Louis6@yahoo.com |
| Beverly | Heller | Beverly_Heller@gmail.com |
| Eugene | Feest | Eugene88@hotmail.com |
| Martin | Bahringer | Martin_Bahringer10@gmail.com |
| Ellis | Miller | Ellis36@hotmail.com |
| Gloria | Cole | Gloria41@gmail.com |
| Linda | Witting | Linda_Witting@yahoo.com |
| Gregg | Kutch | Gregg_Kutch8@yahoo.com |
| Mamie | Raynor | Mamie58@hotmail.com |
| Erick | Bruen | Erick_Bruen13@yahoo.com |
| Faith | Langworth | Faith_Langworth14@gmail.com |
| Alicia | Leannon | Alicia62@yahoo.com |
| Boyd | Mohr | Boyd.Mohr@hotmail.com |
| Lindsey | Heidenreich | Lindsey31@yahoo.com |
| Elsa | Marvin | Elsa.Marvin2@gmail.com |
| Debbie | Hagenes | Debbie.Hagenes@hotmail.com |
| Lionel | McCullough | Lionel_McCullough@gmail.com |
| Kim | Lebsack | Kim.Lebsack66@yahoo.com |
| Rolando | Weissnat | Rolando83@hotmail.com |
| Jacqueline | Lesch | Jacqueline35@hotmail.com |
| Felix | Stokes | Felix77@hotmail.com |
| Renee | Tillman | Renee.Tillman@yahoo.com |
| Richard | Watsica | Richard_Watsica@yahoo.com |
| Nathan | Wolf | Nathan.Wolf@gmail.com |
| Jonathan | Keebler-Crona | Jonathan.Keebler-Crona90@gmail.com |
| Kathleen | Spinka | Kathleen_Spinka58@hotmail.com |
| Bernice | Schinner | Bernice45@hotmail.com |
| Adam | Pagac | Adam58@hotmail.com |
| Earl | Ryan | Earl.Ryan@gmail.com |
| Greg | Bailey | Greg.Bailey@hotmail.com |
| Anne | Powlowski | Anne_Powlowski69@gmail.com |
| Abraham | Dooley | Abraham_Dooley@gmail.com |
| Myron | Lemke | Myron_Lemke@gmail.com |
| Dianna | Gislason-Lesch | Dianna88@hotmail.com |
| Reginald | Hagenes | Reginald_Hagenes51@gmail.com |
| Shelia | Turcotte | Shelia68@yahoo.com |
| Carlton | Jenkins | Carlton_Jenkins62@gmail.com |
| Lance | Wiegand | Lance_Wiegand@gmail.com |
| Ruby | Graham | Ruby20@hotmail.com |
| Hattie | Collier | Hattie60@hotmail.com |
| Viola | Rath | Viola_Rath6@gmail.com |
| Roland | Huel | Roland_Huel@yahoo.com |
| Leticia | Wiegand | Leticia65@hotmail.com |
| Jacqueline | Kulas | Jacqueline.Kulas@hotmail.com |
| Cristina | Jaskolski | Cristina.Jaskolski@hotmail.com |
| Felipe | Daugherty | Felipe_Daugherty@hotmail.com |
| Timothy | Heaney | Timothy.Heaney@gmail.com |
| Alonzo | Kutch | Alonzo12@yahoo.com |
| Keith | Kling | Keith25@yahoo.com |
| Janice | Goyette | Janice93@gmail.com |
| Helen | Kunze-MacGyver | Helen_Kunze-MacGyver@gmail.com |
| Barry | Jast | Barry.Jast@yahoo.com |
| Ramiro | Cummings | Ramiro.Cummings30@hotmail.com |
| Antonio | Little-Bahringer | Antonio.Little-Bahringer@gmail.com |
| Samuel | Zemlak | Samuel_Zemlak@gmail.com |
| Doris | Emard | Doris_Emard8@gmail.com |
| Olivia | Abernathy | Olivia_Abernathy@yahoo.com |
| Justin | Kohler | Justin_Kohler42@hotmail.com |
| Scott | Oberbrunner | Scott.Oberbrunner57@hotmail.com |
| Yolanda | Spinka | Yolanda.Spinka76@hotmail.com |
| Brad | Ullrich-Orn | Brad30@yahoo.com |
| Gloria | Fisher | Gloria.Fisher22@gmail.com |
| Sergio | Crist | Sergio_Crist93@gmail.com |
| Theresa | Sporer | Theresa.Sporer85@hotmail.com |
| Theodore | Wiegand | Theodore58@yahoo.com |
| Rudy | Rowe | Rudy_Rowe25@gmail.com |
| Kurt | Raynor | Kurt.Raynor@hotmail.com |
| Ruth | Medhurst | Ruth.Medhurst97@yahoo.com |
| Tim | Abernathy | Tim0@yahoo.com |
| Rebecca | Runolfsdottir | Rebecca.Runolfsdottir41@gmail.com |
| Angel | Aufderhar | Angel.Aufderhar19@yahoo.com |
| Javier | Bergstrom | Javier12@yahoo.com |
| Leigh | Klocko | Leigh.Klocko77@hotmail.com |
| Taylor | Rice | Taylor30@yahoo.com |
| Cindy | Goldner | Cindy_Goldner47@yahoo.com |
| Shannon | Crist | Shannon88@hotmail.com |
| Sarah | Maggio | Sarah54@hotmail.com |
| Carlton | Langosh-Glover | Carlton.Langosh-Glover@gmail.com |
| Felicia | Roob | Felicia_Roob65@yahoo.com |
| Simon | Kuhic | Simon30@yahoo.com |
| Sharon | Daniel | Sharon.Daniel2@hotmail.com |
| Erin | Bayer | Erin4@hotmail.com |
| Erika | Powlowski-Corwin | Erika33@gmail.com |
| Vicky | Pollich | Vicky_Pollich18@hotmail.com |
| Felicia | Ziemann | Felicia.Ziemann56@gmail.com |
| Colleen | Crooks | Colleen84@hotmail.com |
| Jimmy | Fisher | Jimmy7@yahoo.com |
| Lula | Reichert | Lula.Reichert48@gmail.com |
| Bethany | Schinner | Bethany.Schinner@yahoo.com |
| Allen | Hackett | Allen44@hotmail.com |
No records
Showing 100 records of 500, scroll to bottom to load more
The DataTable triggers onScrollToTop, onScrollToBottom, onScrollToRight and onScrollToLeft callbacks when user scrolls to the top, bottom, left or right edge of the table. You can use the onScrollToBottom event to implement infinite scrolling, like so:
'use client';
import { Button, Group, Paper, Text } from '@mantine/core';
import { notifications } from '@mantine/notifications';
import { DataTable } from 'mantine-datatable';
import { useEffect, useRef, useState } from 'react';
import { employees } from '~/data';
export function InfiniteScrollingExample() {
const batchSize = 100;
const [loading, setLoading] = useState(false);
const [records, setRecords] = useState(employees.slice(0, batchSize));
const scrollViewportRef = useRef<HTMLDivElement>(null);
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
const loadMoreRecords = () => {
if (records.length < employees.length) {
setLoading(true);
timeoutRef.current = setTimeout(() => {
setRecords(employees.slice(0, records.length + batchSize));
setLoading(false);
}, 1000);
} else {
notifications.show({
title: 'No more records',
message: 'All records have been loaded.',
});
}
};
const reset = () => {
setRecords(employees.slice(0, batchSize));
// Make sure to scroll to top after resetting records
scrollViewportRef.current?.scrollTo(0, 0);
};
// Clear timeout on unmount
useEffect(() => {
return () => {
if (timeoutRef.current) clearTimeout(timeoutRef.current);
};
}, []);
return (
<>
<DataTable
withTableBorder
borderRadius="sm"
height={300}
columns={[{ accessor: 'firstName' }, { accessor: 'lastName' }, { accessor: 'email' }]}
records={records}
fetching={loading}
onScrollToBottom={loadMoreRecords}
scrollViewportRef={scrollViewportRef}
/>
<Paper p="md" mt="sm" withBorder>
<Group justify="space-between">
<Text size="sm">
Showing {records.length} records of {employees.length}
{records.length < employees.length && ', scroll to bottom to load more'}
</Text>
<Button variant="light" onClick={reset}>
Reset records
</Button>
</Group>
</Paper>
</>
);
}Head over to the next example to discover more features.











