Universal MarkdownTheme component
import MarkdownTheme from '@app/mdx'MarkdownTheme wraps MDX content and maps markdown elements (headings, paragraphs, lists, blockquotes, links, images) to your design system primitives from @app/ui. It builds on @bacons/mdx ’s MDXComponents, which compiles MDX at build time and accepts custom component overrides per element type.
Element mapping
| Markdown | Rendered as |
|---|---|
h1, h2, h3 | H1, H2, H3 from @app/ui |
p | P |
ul, li | View, Text with list styling |
blockquote | View with left border |
a | Link (external links open in new tab) |
img | MarkdownImage (responsive, layout-aware) |
Web enhancements
On web, MarkdownTheme also:
- Adds
target="_blank"to external links - Renders anchor links (
- #) on headings (click to copy URL, smooth scroll) - Scrolls to
#hashin the URL on mount
Styling
- React Native — Uses
StyleSheetand NativeWindclassNamefor spacing, typography, and layout - Web — Uses
markdown.theme.cssfor typography, list styling, and heading anchor hover states. The CSS targets the#markdown-themewrapper.
- MarkdownTheme.tsx
- markdown.theme.css
Usage
import MarkdownTheme from '@app/mdx'
import ReadMe from './ReadMe.mdx'
<MarkdownTheme>
<ReadMe />
</MarkdownTheme>Last updated on