MonacoJsonField

Read-only Monaco viewer for JSON values. Use in Show or Edit detail contexts where a rich, syntax-highlighted, scrollable view of the JSON is wanted.

Monaco is lazy-loaded the same way as <MonacoJsonInput>.

Usage

import { Show, SimpleShowLayout } from "@/components/admin";
import { MonacoJsonField } from "@/components/monaco";
 
const ProductShow = () => (
  <Show>
    <SimpleShowLayout>
      <MonacoJsonField source="metadata" />
    </SimpleShowLayout>
  </Show>
);

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Field name
autoHeightOptionalbooleantrueFit container to content height
heightOptionalnumber | string200Fixed height (when autoHeight=false)
maxHeightOptionalnumber | string400Upper bound for autoHeight
classNameOptionalstring-Classes on the wrapper
monacoOptionsOptionaleditor.IStandaloneEditorConstructionOptions-Escape hatch — merged into Monaco's options
recordOptionalobjectContextRecord to read from (defaults to RecordContext)
defaultValueOptionalunknown-Fallback when the field is missing from the record

Tips

  • For List cells, use <JsonField> instead — it has no Monaco dependency.
  • Both string and object values are accepted. Strings are displayed verbatim; objects are stringified with 2-space indent.