Skip to main content

RecordRepresentationChip

Renders the record in context as a chip carrying its representation, optionally linking to that record's show or edit view.

It is the chip the reference fields put on screen, and it is exported so a hand-built screen can use the same one. There are two of them, one per layer: RecordRepresentationChip takes an already-resolved link, and SchemaRecordRepresentationChip derives that link from the resource's schema.

Example​

{
/* Inside a Customer show view: the customer's home Category, linked into a dialog */
}
<ReferenceField reference="eshop/category" source="favourite_category_id">
<RecordRepresentationChip
viewType="show"
linkMode="dialog"
renderContent={renderCategory}
/>
</ReferenceField>;

The chip reads the record and the resource from context, so it renders whatever record it is mounted under — inside a SchemaReferenceField that is the referenced record, not the one being shown.

Props​

NameTypeDefaultDescription
size'small' | 'medium''small'MUI chip size
variant'filled' | 'outlined' | 'soft''soft'MUI chip variant
color'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning''primary'MUI chip colour
maxWidthnumber | string—Ellipsizes the representation at this width
iconReactElement | falsean "open in new" glyphfalse renders no icon

It also takes every prop of useRecordLink, which it calls itself: viewType, keepLinkedParent, linkMode, dialogWidth, changeView, openSidePanel and renderContent. Without a viewType the chip is inert — no click, no tooltip.

viewType is already resolved to 'show' or 'edit': deciding whether a resource has such a view needs a schema, which this layer does not read. The tooltip names the view that opens, so a chip pointing at an edit view says "Edit object" and not "Show object".

caution

linkMode: 'dialog' and linkMode: 'panel' need a renderContent to fill the overlay. Without one useRecordLink throws rather than opening an empty dialog — pass one, or leave linkMode unset and let the link navigate.

SchemaRecordRepresentationChip​

The same chip with its link described the way the schema describes it. It accepts every presentational prop above, plus:

NameTypeDefaultDescription
linkboolean | 'show' | 'edit'falseWhether to link, and to which view; true prefers show and falls back to edit
keepLinkedParentbooleanfalseKeeps the linked parent segments in the redirect path
linkMode'page' | 'dialog' | 'panel''page'Surface the target opens on
dialogWidthstring"md"Width for linkMode: 'dialog'

It resolves link against the resource's schema — link={true} links to nothing when the resource exposes neither a show nor an edit view — and supplies the schema's view router as the overlay renderer, so linkMode needs nothing extra from the caller.

<SchemaReferenceField source="category_id" reference="eshop/category" />;
{
/* renders, inside the reference: */
}
<SchemaRecordRepresentationChip link linkMode="dialog" />;
caution

It must be mounted inside the reference, not above it. The resource and record it reads come from context, and inside a reference field those are the referenced ones — resolving the link a level higher would resolve it against the wrong resource.

Wraps arbitrary children in the same record link, for when a chip is not what you want to make clickable:

<SchemaRecordLink link="edit" linkMode="dialog">
<strong>{order.number}</strong>
</SchemaRecordLink>
NameTypeDefaultDescription
linkboolean | 'show' | 'edit'trueWhether to link, and to which view
keepLinkedParentbooleanfalseKeeps the linked parent segments in the redirect path
linkMode'page' | 'dialog' | 'panel''page'Surface the target opens on
dialogWidthstring"md"Width for linkMode: 'dialog'
childrenReactNode—Rendered as-is when there is no view to link to

When the schema offers no matching view the children are returned unwrapped, so a record the user may not open still renders — just without a link.

See also​