dioxus-mdx
MDX parsing and rendering components for Dioxus applications.
Parse Mintlify-style MDX into an AST and render it with pre-built Dioxus components — callouts, cards, tabs, code groups, accordions, steps, and more. Includes syntax highlighting, frontmatter extraction, and OpenAPI spec parsing.
Quick Start
Add to your Cargo.toml:
[]
= "0.7"
Render MDX content in a component:
use *;
use MdxContent;
Parsing Only
Use the parser directly without rendering:
use ;
let doc = parse_document;
assert_eq!;
// Parse content without frontmatter
let nodes = parse_mdx;
Supported Components
| Component | MDX Syntax |
|---|---|
| Callouts | <Tip>, <Note>, <Warning>, <Info> |
| Cards | <Card>, <CardGroup> |
| Tabs | <Tabs>, <Tab> |
| Steps | <Steps>, <Step> |
| Accordion | <AccordionGroup>, <Accordion> |
| Code | <CodeGroup>, fenced code blocks with syntax highlighting |
| API Docs | <ParamField>, <ResponseField>, <Expandable> |
| Examples | <RequestExample>, <ResponseExample> |
| Changelog | <Update> |
OpenAPI Support
Parse OpenAPI/Swagger specs and render interactive API reference pages:
use parse_openapi;
let spec = parse_openapi.unwrap;
The EndpointPage component renders a two-column Mintlify-style API reference for each operation.
Syntax Highlighting
Code blocks get automatic syntax highlighting via dioxus-code. DocCodeBlock and DocCodeGroup render through it on both server and wasm targets — no extra wiring required.
The crate ships a common set of languages baked in (bash, css, dockerfile, html, javascript, json, markdown, python, rust, toml, typescript, yaml; lang-c-sharp, lang-cpp and lang-tsx are available but off by default). To support more, add dioxus-code directly to your Cargo.toml with the desired lang-* features — Cargo unifies them into the transitive dep, so no fork or wrapper feature is needed.
Styling Setup
Components use Tailwind CSS 4 with DaisyUI 5 and @tailwindcss/typography.
When using as a crates.io dependency, Tailwind can't scan the crate source.
Copy safelist.html from the crate into your project root and add it as a source:
@/
When using as a workspace path dependency, point directly at the source:
@////**/
Components use semantic DaisyUI classes (bg-base-200, text-base-content, text-primary, etc.)
and adapt to any DaisyUI theme.
Features
web(default) — enables web-specific features like clipboard copy buttons on code blockshighlight(default) — syntax-highlights code blocks viadioxus-code. Disable (default-features = false) to drop the dependency and its C-compiling tree-sitter grammars: no C toolchain is needed for wasm and the binary is smaller, but code blocks render as plain (uncolored) text. Turning it off also removes theCodeTheme,Theme, andCodeThemeOverridere-exports.lang-*— one tree-sitter grammar each, on top ofhighlight.highlighton its own highlights Rust only (dioxus-code'sruntimealways compiles it, solang-rustneeds nothing extra). The default set addslang-bash,lang-css,lang-dockerfile,lang-html,lang-javascript,lang-json,lang-markdown,lang-python,lang-toml,lang-typescriptandlang-yaml;lang-c-sharp,lang-cppandlang-tsxare available but off by default (their grammars are the largest). For any other language, depend ondioxus-codedirectly —dioxus-code = { version = "0.1", default-features = false, features = ["runtime", "lang-go"] }— and cargo unifies the grammar into the copy this crate uses. A fence whose grammar is not compiled in renders as plain text in the same markup.openapi(default) — parses OpenAPI specs:parse_openapi()and inline<OpenAPI>…</OpenAPI>blocks. Disable to dropopenapiv3andserde_yaml(and itsunsafe-libyaml) from the build. TheOpenApiSpectypes and the viewer components (OpenApiViewer,EndpointPage, …) stay available — only spec parsing goes away, so an<OpenAPI>block falls through to the markdown branch and its body renders as text. Frontmatter parsing is unaffected: it uses the built-inparse_yaml_litesubset parser, notserde_yaml.
License
MIT