documentation/docs/ui-integrations/mantine/components/fields/date-field/index.md
This field is used to display dates. It uses Day.js to display date format.
:::simple Good to know
You can swizzle this component to customize it with the Refine CLI
:::
Let's see how we can use <DateField> with the example in the post list.
setInitialRoutes(["/posts"]);
// visible-block-start
import { List, DateField } from "@refinedev/mantine";
import { Table, Pagination } from "@mantine/core";
import { useTable } from "@refinedev/react-table";
import { ColumnDef, flexRender } from "@tanstack/react-table";
const PostList: React.FC = () => {
const columns = React.useMemo<ColumnDef<IPost>[]>(
() => [
{
id: "id",
header: "ID",
accessorKey: "id",
},
{
id: "title",
header: "Title",
accessorKey: "title",
},
{
id: "createdAt",
header: "Created At",
accessorKey: "createdAt",
cell: function render({ getValue }) {
return (
// highlight-next-line
<DateField format="LLL" value={getValue()} />
);
},
},
],
[],
);
const {
reactTable: { getHeaderGroups, getRowModel },
refineCore: { setCurrentPage, pageCount, currentPage },
} = useTable({
columns,
});
return (
<List>
<Table>
<thead>
{getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<th key={header.id}>
{header.isPlaceholder
? null
: flexRender(
header.column.columnDef.header,
header.getContext(),
)}
</th>
))}
</tr>
))}
</thead>
<tbody>
{getRowModel().rows.map((row) => (
<tr key={row.id}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
))}
</tbody>
</Table>
<Pagination
position="right"
total={pageCount}
page={currentPage}
onChange={setCurrentPage}
/>
</List>
);
};
interface IPost {
id: number;
title: string;
createdAt: string;
}
// visible-block-end
render(
<ReactRouter.BrowserRouter>
<RefineMantineDemo
resources={[
{
name: "posts",
list: "/posts",
},
]}
>
<ReactRouter.Routes>
<ReactRouter.Route
path="/posts"
element={
<div style={{ padding: 16 }}>
<ReactRouter.Outlet />
</div>
}
>
<ReactRouter.Route index element={<PostList />} />
</ReactRouter.Route>
</ReactRouter.Routes>
</RefineMantineDemo>
</ReactRouter.BrowserRouter>,
);
:::simple External Props
It also accepts all props of Mantine Text.
:::