Mantine UI & mantine-datatable
Overviewβ
The application uses Mantine UI as the component library for consistent, accessible UI primitives. For data grids/tables, we use mantine-datatable when we need lightweight, accessible tabular components.
Installationβ
pnpm add @mantine/core @mantine/hooks @mantine/form @mantine/notifications
pnpm add mantine-datatable
Provider setup (in app/layout.tsx)β
'use client';
import { MantineProvider } from '@mantine/core';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<MantineProvider withGlobalStyles withNormalizeCSS>
{children}
</MantineProvider>
</body>
</html>
);
}
Themingβ
- Use Mantine theme tokens and
MantineProviderto centralize colors and typography - Prefer design tokens from the
themeobject instead of hard-coded values
Example: datatable usageβ
import { DataTable } from 'mantine-datatable';
export function EmployeesTable({ data }) {
return (
<DataTable
records={data}
columns={[{ accessor: 'name' }, { accessor: 'email' }, { accessor: 'department' }]}
totalRecords={data.length}
// Add pagination, sorting handlers integrated with TanStack Query
/>
);
}
Accessibilityβ
- Ensure table headers are semantic
- Support keyboard navigation and focus states
- Provide visible focus styles via Mantine theme
Performanceβ
- Virtualize long lists where needed
- Offload heavy work to server or worker threads
- Use memoization (
useMemo,React.memo) for row renderers
Integration tipsβ
- Combine
mantine-datatablewith server-side pagination from the API - Provide stable
keyprops for rows - Use
TanStack Queryto cache pages and prefetch next pages
Component patternsβ
- Small presentational components in
src/components/ui/ - Composite components that combine data fetching live in
src/components/containers/ - Keep styles co-located when using CSS modules or Tailwind utility classes
Related docsβ
Resourcesβ
- Mantine: https://mantine.dev/
- mantine-datatable: https://github.com/SarahDayan/mantine-datatable