+
+
+ {lastSort ?? 'Sort by any column, then reset'}
+
+
+ setLastSort(`sorted by "${col.id}" ${dir}`)}
+ highlightOnHover
+ />
+
+ );
+}
diff --git a/apps/docs/src/layouts/DocsLayout.astro b/apps/docs/src/layouts/DocsLayout.astro
index b7a0d3da..b06e1655 100644
--- a/apps/docs/src/layouts/DocsLayout.astro
+++ b/apps/docs/src/layouts/DocsLayout.astro
@@ -60,6 +60,7 @@ const nav = [
{ label: 'Animations', href: '/docs/animations' },
{ label: 'Accessibility', href: '/docs/accessibility' },
{ label: 'RTL Support', href: '/docs/rtl' },
+ { label: 'Mobile', href: '/docs/mobile' },
],
},
{
diff --git a/apps/docs/src/pages/docs/api.md b/apps/docs/src/pages/docs/api.md
index 798f5028..b1c518eb 100644
--- a/apps/docs/src/pages/docs/api.md
+++ b/apps/docs/src/pages/docs/api.md
@@ -47,6 +47,7 @@ Complete reference for every prop, type, and export in `react-data-table-compone
| `responsive` | `boolean` | `true` | Wrap the table in a horizontally scrollable container. |
| `fixedHeader` | `boolean` | `false` | Stick the column header at the top when scrolling. |
| `fixedHeaderScrollHeight` | `string` | `"100vh"` | Max height of the scrollable body when `fixedHeader` is on. |
+| `onScroll` | `(event) => void` | - | Called when the user scrolls the table body. Works with both `fixedHeader` enabled and disabled. |
| `direction` | `Direction` | `"ltr"` | Text direction (`ltr`, `rtl`, `auto`). |
| `className` | `string` | - | Extra CSS class on the root element. |
| `style` | `CSSProperties` | - | Inline styles on the root element. |
@@ -77,6 +78,7 @@ Complete reference for every prop, type, and export in `react-data-table-compone
| `sortFunction` | `SortFunction \| null` | - | Global custom sort function applied to all sortable columns. |
| `sortIcon` | `ReactNode` | built-in chevron | Custom sort direction indicator. |
| `onSort` | `(column, direction, sortedRows) => void` | - | Called whenever the sort column or direction changes. |
+| `ref.clearSort()` | `DataTableHandle` | - | Imperatively reset sort to the default state. See [DataTableHandle](#datatablehandle-ref). |
### Pagination
@@ -124,6 +126,7 @@ Column-level footers live on each [`TableColumn`](#tablecolumnt) as the `foot
| `selectableRowsComponentProps` | `object` | - | Extra props forwarded to the custom checkbox component. |
| `onSelectedRowsChange` | `(state) => void` | - | Called whenever selection changes. Receives `{ allSelected, selectedCount, selectedRows }`. |
| `clearSelectedRows` | `boolean` | - | **Deprecated.** Toggle to clear selection. Use `ref.current.clearSelectedRows()` instead. |
+| `ref.clearSelectedRows()` | `DataTableHandle` | - | Imperatively deselect all selected rows. See [DataTableHandle](#datatablehandle-ref). |
### Expandable rows
@@ -150,7 +153,6 @@ Column-level footers live on each [`TableColumn`](#tablecolumnt) as the `foot
| `onRowMiddleClicked` | `(row, event) => void` | Called when a row is middle-clicked (scroll-click). Use with `onRowClicked` to implement open-in-new-tab behaviour. |
| `onRowMouseEnter` | `(row, event) => void` | Called when the pointer enters a row. |
| `onRowMouseLeave` | `(row, event) => void` | Called when the pointer leaves a row. |
-| `onScroll` | `(event) => void` | Called when the user scrolls the table body. Works with both `fixedHeader` enabled and disabled. |
### Column features
@@ -312,9 +314,8 @@ function App() {
return (
<>
-
+
+
>
);
@@ -324,6 +325,7 @@ function App() {
| Method | Description |
|---|---|
| `clearSelectedRows()` | Deselect all currently selected rows. |
+| `clearSort()` | Reset sort to the default (`defaultSortFieldId` / `defaultSortAsc`), or unsorted if no defaults are set. |
## TableStyles
diff --git a/apps/docs/src/pages/docs/changelog.astro b/apps/docs/src/pages/docs/changelog.astro
index a7dd5109..61d80de5 100644
--- a/apps/docs/src/pages/docs/changelog.astro
+++ b/apps/docs/src/pages/docs/changelog.astro
@@ -11,10 +11,15 @@ import CodeBlock from '../../components/CodeBlock.astro';
repository on GitHub.
-
8.2.0 (unreleased)
+
8.2.0
New features
+
+ paginationPosition — controls where the pagination bar renders relative to the
+ table. Accepts 'bottom' (default), 'top', or 'both'.
+ → Pagination docs
+
paginationPage — controlled active-page prop. Set it to navigate the table
programmatically (e.g. reset to page 1 after a filter change). Use together with
@@ -34,6 +39,22 @@ import CodeBlock from '../../components/CodeBlock.astro';
and "Last Page" are now configurable via paginationComponentOptions, enabling
proper i18n for screen readers.
+
+ ref.clearSort() — new DataTableHandle method to programmatically
+ reset sort back to its default state (defaultSortFieldId / defaultSortAsc),
+ or unsorted if no defaults are set.
+ → Sorting docs
+
+
+ Sortable column indicator — sortable columns now show a faint sort icon at
+ reduced opacity so users can discover which columns are sortable before clicking. The inactive
+ opacity is themable via the --rdt-sort-icon-inactive-opacity CSS custom property
+ (default 0.3).
+
+
+ onScroll — new prop that fires whenever the table's scroll wrapper scrolls.
+ Receives the native React.UIEvent<HTMLDivElement>.
+
Bug fixes
diff --git a/apps/docs/src/pages/docs/fixed-header.astro b/apps/docs/src/pages/docs/fixed-header.astro
index 8df199aa..7ef652a2 100644
--- a/apps/docs/src/pages/docs/fixed-header.astro
+++ b/apps/docs/src/pages/docs/fixed-header.astro
@@ -3,6 +3,7 @@ import DocsLayout from '../../layouts/DocsLayout.astro';
import Demo from '../../components/Demo.astro';
import CodeBlock from '../../components/CodeBlock.astro';
import FixedHeaderDemo from '../../components/demos/FixedHeaderDemo.tsx';
+import OnScrollDemo from '../../components/demos/OnScrollDemo.tsx';
---
@@ -82,6 +83,29 @@ const columns: TableColumn[] = [
selectableRows
/>`} />
+
Tracking scroll position with onScroll
+
+ The onScroll prop fires on every scroll event inside the table body. It receives a
+ standard React.UIEvent<HTMLDivElement> so you can read scrollTop,
+ scrollLeft, or any other scroll geometry from event.target.
+
@@ -110,6 +134,12 @@ const columns: TableColumn[] = [
Only applies when fixedHeader is true.
+
+
onScroll
+
(event: React.UIEvent<HTMLDivElement>) => void
+
-
+
Called when the user scrolls the table body. Works with both fixedHeader enabled and disabled.
+
diff --git a/apps/docs/src/pages/docs/mobile.astro b/apps/docs/src/pages/docs/mobile.astro
new file mode 100644
index 00000000..a230376b
--- /dev/null
+++ b/apps/docs/src/pages/docs/mobile.astro
@@ -0,0 +1,107 @@
+---
+import DocsLayout from '../../layouts/DocsLayout.astro';
+import Demo from '../../components/Demo.astro';
+import CodeBlock from '../../components/CodeBlock.astro';
+import MobileDemo from '../../components/demos/MobileDemo.tsx';
+---
+
+
+
Mobile
+
+
+ A data table is fundamentally a desktop pattern — comparing values across rows requires seeing
+ multiple columns at once. On small screens the table stays a table, but several defaults are
+ tuned to make that experience as comfortable as possible.
+
+ The table wraps in a horizontally-scrollable container with momentum scrolling and
+ scroll-chaining prevention. On touch devices users can swipe left/right to reveal hidden columns
+ without disrupting the page's vertical scroll.
+
+
+
Hiding columns on small screens
+
+
+ Use the hide property on a column to remove it below a breakpoint.
+ The column header and all its cells disappear — the remaining columns fill the available width.
+
+ You can also pass a numeric pixel value to hide at a custom breakpoint:
+
+
+ r.notes, hide: 480 }`} />
+
+
Pagination on small screens
+
+
+ Below 600px the rows-per-page label and the current-range text (1–5 of 30) are hidden
+ automatically, giving the pagination controls more breathing room. The rows-per-page select and
+ nav buttons remain.
+
+
+
Touch targets
+
+
+ Row height enforces a minimum of 48px on small screens so tap targets meet accessibility
+ guidelines. Pagination buttons expand to 44×44px. Cell padding tightens slightly
+ (--rdt-cell-padding-x-mobile, default 12px) to reclaim horizontal space.
+
+
+
CSS custom properties
+
+
You can override the mobile padding via CSS variables on the table container:
+
+
+
+
Recommendations for app developers
+
+
+ For apps where the primary use case on mobile is looking up a single record rather than
+ comparing rows, consider rendering a completely different component below your breakpoint —
+ a simple list or card feed — and only mounting DataTable on wider viewports:
+
+
+ ;
+ }
+
+ return ;
+}`} />
+
diff --git a/apps/docs/src/pages/docs/sorting.astro b/apps/docs/src/pages/docs/sorting.astro
index 122a33cd..808cda5c 100644
--- a/apps/docs/src/pages/docs/sorting.astro
+++ b/apps/docs/src/pages/docs/sorting.astro
@@ -6,6 +6,7 @@ import SortingDemo from '../../components/demos/SortingDemo.tsx';
import PrioritySortDemo from '../../components/demos/PrioritySortDemo.tsx';
import ServerSideSortingDemo from '../../components/demos/ServerSideSortingDemo.tsx';
import ServerSideSortPaginationDemo from '../../components/demos/ServerSideSortPaginationDemo.tsx';
+import SortResetDemo from '../../components/demos/SortResetDemo.tsx';
---
@@ -323,12 +324,46 @@ export default function App() {
+
Resetting sort programmatically
+
+ Attach a ref to DataTable and call ref.current.clearSort() to reset
+ the sort back to its default state (defaultSortFieldId / defaultSortAsc,
+ or unsorted if no defaults are set). Useful when the user switches a view mode that makes the
+ current sort invalid.
+