Skip to main content
Version: 57.2.0

Add a custom admin field widget

  1. Name the widget in model admin metadata:
admin: {
displayName: "Articles",
listFields: ["title", "body"],
fieldOverrides: {body: {widget: "rich-text"}},
}
  1. Implement the field widget:
const RichTextWidget: React.FC<AdminFieldWidgetProps> = ({
value,
onChange,
readOnly,
}) => (
<RichTextEditor
disabled={Boolean(readOnly)}
onChange={onChange}
value={typeof value === "string" ? value : ""}
/>
);
  1. Register it once around the admin routes:
<AdminProvider
api={api}
apiBase="/admin"
routeBase="/admin"
widgets={{fields: {"rich-text": RichTextWidget}}}
>
<AdminRoutes />
</AdminProvider>

Host registrations override built-ins with the same ID.