MarkdownViewer
MarkdownViewer renders Markdown from an OSDK Media object, and BaseMarkdownViewer renders a Markdown string you provide.
Rendering uses react-markdown and supports headings, code blocks, tables, links, images, blockquotes, and lists, all themeable through CSS custom properties.
Import
import {
BaseMarkdownViewer,
MarkdownViewer,
} from "@osdk/react-components/markdown-viewer";MarkdownViewer— Primary component for OSDK usage. Accepts an OSDKMediaobject, handles fetching the markdown text, and renders viaBaseMarkdownViewer.BaseMarkdownViewer— Lower-level component that accepts a markdown string directly.
Usage
With OSDK Media
import { MarkdownViewer } from "@osdk/react-components/markdown-viewer";
<MarkdownViewer media={document.readme} />;With a string
import { BaseMarkdownViewer } from "@osdk/react-components/markdown-viewer";
<BaseMarkdownViewer content="# Hello World\n\nThis is **bold** text." />;Props
BaseMarkdownViewerProps
| Prop | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Markdown text to render |
className | string | No | CSS class applied to the root element |
MarkdownViewerProps
| Prop | Type | Required | Description |
|---|---|---|---|
media | Media | Yes | The OSDK Media object to fetch markdown from |
className | string | No | CSS class applied to the root element |
Features
Supported markdown elements
- Headings (h1–h6)
- Paragraphs and line breaks
- Bold, italic, and
strikethroughtext - Links and images
- Inline
codeand fenced code blocks - Blockquotes
- Ordered and unordered lists
- Tables
- Horizontal rules
Theming
All colors and sizes are driven by CSS custom properties defined in CSS Variables. Override them to match your application theme:
:root {
--osdk-markdown-viewer-bg: #ffffff;
--osdk-markdown-viewer-border: 1px solid #e0e0e0;
--osdk-markdown-viewer-padding: 24px;
--osdk-markdown-viewer-line-height: 1.6;
--osdk-markdown-viewer-heading-margin-top: 1.5em;
--osdk-markdown-viewer-heading-margin-bottom: 0.5em;
--osdk-markdown-viewer-paragraph-spacing: 1em;
--osdk-markdown-viewer-code-bg: #f5f5f5;
--osdk-markdown-viewer-table-border: #e0e0e0;
}