documentation/docs/ui-integrations/mantine/components/fields/boolean-field/index.md
This field is used to display boolean values. It uses the <Tooltip> values from Mantine.
:::simple Good to know
You can swizzle this component to customize it with the Refine CLI
:::
Let's see how we can use <BooleanField> with the example in the post list.
setInitialRoutes(["/posts"]);
// visible-block-start
import { List, BooleanField } from "@refinedev/mantine";
import { Table, Pagination } from "@mantine/core";
import { useTable } from "@refinedev/react-table";
import { ColumnDef, flexRender } from "@tanstack/react-table";
import { IconX, IconCheck } from "@tabler/icons-react";
const PostList: React.FC = () => {
const columns = React.useMemo<ColumnDef<IPost>[]>(
() => [
{
id: "id",
header: "ID",
accessorKey: "id",
},
{
id: "title",
header: "Title",
accessorKey: "title",
},
{
id: "status",
header: "Status",
accessorKey: "status",
cell: function render({ getValue }) {
return (
// highlight-start
<BooleanField
value={getValue() === "published"}
trueIcon={<IconCheck />}
falseIcon={<IconX />}
valueLabelTrue="published"
valueLabelFalse="unpublished"
/>
// highlight-end
);
},
},
],
[],
);
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;
status: "published" | "draft" | "rejected";
}
// 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 Tooltip.
:::