Create
<Create> provides us a layout to display the page. It does not contain any logic but adds extra functionalities like action buttons and giving titles to the page.
We will show what <Create> does using properties with examples.
You can swizzle this component to customize it with the Refine CLI
Properties
title
title allows you to add a title inside the <Create> component. If you don't pass the title props, it uses the "Create" prefix and the singular resource name by default. For example, for the /posts/create resource, it would be "Create post".
saveButtonProps
The <Create> component has a save button that submits the form by default. If you want to customize this button you can use the saveButtonProps property:
For more information, refer to the
<SaveButton>documentation →
resource
The <Create> component reads the resource information from the route by default. If you want to use a custom resource for the <Create> component, you can use the resource prop:
If you have multiple resources with the same name, you can pass the identifier instead of the name of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the name of the resource defined in the <Refine/> component.
For more information, refer to the
identifiersection of the<Refine/>component documentation →
goBack
To customize the back button or to disable it, you can use the goBack property:
If your route has no :action parameter or your action is list, the back button will not be shown even if you pass a goBack property. You can override this behavior by using the headerProps property:
import { useBack } from "@refinedev/core";
import { Create } from "@refinedev/antd";
import { Button } from "antd";
const PostCreate: React.FC = () => {
const back = useBack();
const BackButton = () => <Button>←</Button>;
return (
<Create goBack={<BackButton />} headerProps={{ onBack: back }}>
<p>Rest of your page here</p>
</Create>
);
};
isLoading
To toggle the loading state of the <Create/> component, you can use the isLoading property:
breadcrumb Globally ConfigurableThis value can be configured globally. Click to see the guide for more information.
To customize or disable the breadcrumb, you can use the breadcrumb property. By default the Breadcrumb component from the @refinedev/antd package is used for breadcrumbs.
For more information, refer to the
Breadcrumbdocumentation →
wrapperProps
You can use the wrapperProps property if you want to customize the wrapper of the <Create/> component. The @refinedev/antd wrapper elements are simply <div/>s and wrapperProps and can get every attribute that <div/> can get.
headerProps
You can use the headerProps property to customize the header of the <Create/> component:
For more information, refer to the
PageHeaderdocumentation →
contentProps
You can use the contentProps property to customize the content of the <Create/> component:
For more information, refer to the
Carddocumentation →
headerButtons
You can customize the buttons at the header by using the headerButtons property. It accepts React.ReactNode or a render function ({ defaultButtons }) => React.ReactNode which you can use to keep the existing buttons and add your own.
headerButtonProps
You can use the headerButtonProps property to customize the wrapper element of the buttons at the header:
For more information, refer to the
Spacedocumentation →
footerButtons
By default, the <Create/> component has a <SaveButton> at the footer.
You can customize the buttons at the footer by using the footerButtons property. It accepts React.ReactNode or a render function ({ defaultButtons, saveButtonProps }) => React.ReactNode which you can use to keep the existing buttons and add your own.
Or, instead of using the defaultButtons, you can create your own buttons. If you want, you can use saveButtonProps to utilize the default values of the <SaveButton> component.
footerButtonProps
You can customize the wrapper element of the buttons at the footer by using the footerButtonProps property.
For more information, refer to the
Spacedocumentation →
API Reference
Properties
| Property | Type | Description | Default |
|---|---|---|---|
resource | | Resource name for API data interactions | Reads |
title | | Title of the create view | Create {resource.name} |
wrapperProps | | Props for the wrapper component of the view | |
headerProps | Props for the header component | ||
contentProps | | Props for the content wrapper component | |
breadcrumb | | Breadcrumb to be displayed in the header |
|
goBack | | Back button element at the top left of the page |
|
headerButtons | | Header action buttons to be displayed in the header |
|
headerButtonProps | Additional props to be passed to the wrapper of the header buttons | ||
footerButtons | | Footer action buttons to be displayed in the footer |
|
footerButtonProps | Additional props to be passed to the wrapper of the footer buttons | ||
isLoading | | Loading state of the component | |
saveButtonProps | | Additional props for the |
</rewritten_file>