MdxField

Shows a markdown string as formatted text in a read-only editor.

Installation

pnpm dlx shadcn@latest add @chelone/mdx-editor

<MdxField> renders a markdown string as formatted text: headings, lists, links, images and tables. Use it where the value is long-form content, such as a show view.

It is an add-on installed from the registry, with the editor as an optional peer dependency. The MdxInput page covers installing it, the style import, and how the React and Vue editors differ.

In a show view

import { RecordField, Show } from "@/components/admin";
import { MdxField } from "@/components/mdx-editor";
 
export const PostShow = () => (
  <Show>
    <RecordField source="body">
      <MdxField source="body" empty="No content" />
    </RecordField>
  </Show>
);

A missing value shows empty. A string is translated, and in React a node renders as-is. In Vue, the #empty slot replaces the editor.

For a list cell, use TextField. It prints plain text and loads no editor, so a datagrid of many rows stays light.

Props

PropTypeDefaultDescription
cellClassNamestring—A class name to apply to the cell element when used inside `<DataTable>`.
classNamestring—A class name to apply to the root element.
emptyReactNode—The node to display when the field value is empty. Defaults to nothing. A string is translated; a ReactNode renders as-is.
headerClassNamestring—A class name to apply to the header cell element when used inside `<DataTable>`.
labelReactNode—Label to use as column header when using `<DataTable>` or `<SimpleShowLayout>`. Defaults to the capitalized field name. Set to `false` to disable the label.
pluginsRealmPlugin[]—The editor plugins. Defaults to `defaultFieldPlugins`.
recordRecordType—The record to render. Defaults to the ambient `RecordContext` value.
resourcestring—The resource name. Defaults to the ambient `ResourceContext` value.
sortableboolean—Disable the header click handler when used inside `<DataTable>`.
sortBystring—The field to sort by when this column head is clicked, if sortable.
sortByOrderSortOrder—The order used for sorting when this column head is clicked, if sortable.
sourcestring—Name of the property to display (dot/bracket path).
textAlignTextAlign—The text alignment for the cell content, when used inside `<DataTable>`.

Vue takes class, crepe-config, default-value and empty besides source and record, and has none of the other props above. To edit the value, use MdxInput.