List
<List>
provides us a layout to display the page. It does not contain any logic but adds extra functionalities like a create button or giving the page titles.
We will show what <List>
does using properties with examples.
Properties
canCreate
and createButtonProps
canCreate
allows us to add the create button inside the <List>
component. If resource is passed a create component, refine adds the create button by default. If you want to customize this button you can use createButtonProps
property like the code below.
Create button redirects to the create page of the resource according to the value it reads from the URL.
import { usePermissions } from "@pankod/refine-core";
import { List } from "@pankod/refine-mui";
export const ListPage: React.FC = () => {
const { data } = usePermissions<string>();
return (
<List
canCreate={data === "admin"}
createButtonProps={{ size: "small" }}
>
...
</List>
);
};
Refer to the usePermission
documentation for detailed usage. β
cardProps
<List>
uses the Material UI <Card>
components so you can customize with the props of cardProps
.
cardHeaderProps
<List>
uses the Material UI <CardHeader>
components so you can customize with the props of cardHeaderProps
.
import { List, Typography } from "@pankod/refine-mui";
export const CreatePage: React.FC = () => {
return (
<List
cardHeaderProps={{
title: <Typography variant="h5">Custom Title</Typography>,
}}
>
...
</List>
);
};

cardContentProps
<List>
uses the Material UI <CardContent>
components so you can customize with the props of cardContentProps
.
resource
The <List>
component reads the resource
information from the route by default. This default behavior will not work on custom pages. If you want to use the <List>
component in a custom page, you can use the resource
prop.
Refer to the custom pages documentation for detailed usage. β
import { Refine } from "@pankod/refine-core";
import { List } from "@pankod/refine-mui";
import routerProvider from "@pankod/refine-react-router-v6";
import dataProvider from "@pankod/refine-simple-rest";
const CustomPage = () => {
return <List resource="posts">...</List>;
};
export const App: React.FC = () => {
return (
<Refine
routerProvider={{
...routerProvider,
routes: [
{
element: <CustomPage />,
path: "/custom",
},
],
}}
dataProvider={dataProvider("https://api.fake-rest.refine.dev/")}
resources={[{ name: "posts" }]}
/>
);
};
API Reference
Properties
Property | Description | Type | Default |
---|---|---|---|
canCreate | Adds a <CreateButton> | React.ReactNode | <SaveButton> and depending on your resource configuration (canDelete prop) |
createButtonProps | Adds props for <CreateButton> | { disabled: boolean; onClick: () => void; loading: boolean; } | <SaveButton> |
cardProps | Passes the props for <Card> | CardProps | <SaveButton> and depending on your resource configuration (canDelete prop) |
cardHeaderProps | Passes the props for <CardHeader> | CardHeaderProps | |
cardContentProps | Passes the props for <CardContent> | CardContentProps | |
resource | Resource name for API data interactions | string | Resource name that it reads from the URL. |