Migrating from Material React Table
If you know Material React Table (MRT) v3, most of the API carries over by name. The differences come from three places: Svelte instead of React, shadcn-svelte instead of MUI, and TanStack Table v9 instead of v8.
From React to Svelte
Section titled “From React to Svelte”| React | Svelte |
|---|---|
<MaterialReactTable table={table} /> | <ShadcnSvelteTable {table} /> |
useMaterialReactTable({ ... }) | createShadcnSvelteTable({ ... }) |
useState for controlled state | $state, passed to the table as a getter |
renderTopToolbar, renderDetailPanel | A snippet: topToolbar, detailPanel (drop render, lowercase) |
Cell: ({ cell }) => <b>{...}</b> | Cell is a snippet: {#snippet cell({ cell })}…{/snippet} |
muiTableBodyCellProps | tableBodyCellProps (drop mui) |
sx / style objects | style strings and CSS |
ref options | The same option names, but a { current } holder |
memoMode | Not needed: Svelte updates only what changed |
Snippets instead of render props
Section titled “Snippets instead of render props”Every renderX option became a snippet. The render prefix is gone and the name starts in lower case:
{#snippet detailPanel({ row })} <pre>{JSON.stringify(row.original, null, 2)}</pre>{/snippet}
<ShadcnSvelteTable options={{ columns, data, detailPanel }} />Column-level snippets keep their capital letters (Cell, Header, Footer, Edit, Filter, AggregatedCell,
GroupedCell, PlaceholderCell), because header and footer are already the plain-text options.
renderedCellValuein aCellsnippet is the raw value, not a rendered node.- Menu snippets (
rowActionMenuItems,columnActionsMenuItems,cellActionMenuItems) receiveinternalMenuItems: the built-in items as snippets, which you can render with{@render item()}. createRowDialogContentandeditRowDialogContentreceiveinternalEditCells(the cells being edited). Render each with<MRT_EditCellTextField {cell} {table} />.
From MUI to shadcn-svelte
Section titled “From MUI to shadcn-svelte”- The table markup is plain
<table>elements with our own CSS. shadcn-svelte (built on bits-ui and Tailwind) provides the buttons, checkboxes, menus, dialog, switches and text fields. - Import
shadcn-svelte-tanstack-table/styles.cssafter Tailwind and theme with the shadcn CSS variables (--primary,--card, …). There is no theme provider. - There are no MUI date pickers. Date, datetime and time filters use native
<input type="date | datetime-local | time">. Date values reach your filter functions asDateobjects (HH:mmstrings for time). - Autocomplete filters use a native
<datalist>, and tooltips use the nativetitleattribute.
From TanStack Table v8 to v9
Section titled “From TanStack Table v8 to v9”Shadcn Svelte Table registers the v9 features, row models and function registries for you, but some names changed and they show up in your options:
| v8 / MRT v3 | v9 |
|---|---|
sortingFn, sortingFns | sortFn, sortFns |
Pin 'left' / 'right' | 'start' / 'end' (also in columnPinning state and inset-inline) |
columnSizingInfo state | columnResizing (setColumnResizing) |
getState() | table.atoms.<slice>.get() or table.store.get() |
filterFns, sortFns, aggregationFns options | Still options, but registered once when the table is created |
arrIncludesSome | Needs array cells. multi-select filters now default to arrIncludes |
table.getPrePaginationRowModel() | table.getPrePaginatedRowModel() |
What is not ported (yet)
Section titled “What is not ported (yet)”memoMode, MUI-specific props (sx, muiXProps) and the MUI date pickers have no equivalent. Everything else in
the React docs has a counterpart under the same name.