Skip to main content
Version: 4.xx.xx

Custom Inputs

refine uses Ant Design's <Form> components to control and work with form data. Ant Design supports custom form items inside the <Form.Item> components. These items should be controllable via their value property and should implement onChange (or a custom callback name specified by <Form.Item>'s trigger prop).

For some data types, displaying and editing as plain text may cause user experience problems.

Custom components may be useful when working with markdown (with markdown editor), JSON based rich text (draft, quill like editors), and HTML (a HTML editor). It can be used in table columns and form fields

Refer to the Ant Design docs for more detailed information about <Form>. β†’

Example​

We will demonstrate how to use custom input fields for markdown data by adding a markdown editor to edit and create forms.

/src/pages/posts/edit.tsx
import React, { useState } from "react";
import { Edit, useForm } from "@refinedev/antd";
import { Form, Input } from "antd";

import MDEditor from "@uiw/react-md-editor";

import { IPost } from "interfaces";

export const PostEdit: React.FC = (props) => {
const { formProps, saveButtonProps } = useForm<IPost>();

return (
<Edit {...props} saveButtonProps={saveButtonProps}>
<Form {...formProps} layout="vertical">
<Form.Item
label="Title"
name="title"
rules={[
{
required: true,
},
]}
>
<Input />
</Form.Item>
<Form.Item
label="Content"
name="content"
rules={[
{
required: true,
},
]}
>
<MDEditor data-color-mode="light" />
</Form.Item>
</Form>
</Edit>
);
};
Markdown input

Example​

RUN IN YOUR LOCAL
npm create refine-app@latest -- --example input-custom