Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
A small Dioxus component for rendering source code with proper highlighting. Parsing is powered by arborium; themes ship as scoped CSS so you can mix several on one page.
Two ways to highlight:
code!()macro — parses at compile time. The runtime ships only the spans, no parser. Default.SourceCode— parses at runtime. Opt in with theruntimefeature when the source isn't known until the user types it.
Quick start
[]
= "0.1"
use *;
use ;
The path is resolved from the consumer's CARGO_MANIFEST_DIR. concat! and env! work too.
Runtime highlighting
For editor-style use cases where the source isn't known at compile time:
[]
= { = "0.1", = ["runtime"] }
use ;
rsx!
Language can be set explicitly, inferred from a filename via with_name("main.rs"), or auto-detected from the source. The default runtime feature includes Rust; pass lang-python, lang-toml, or all-languages for the rest.
Editor
dioxus-code-editor is a sibling crate that pairs the highlighter with a contenteditable input layer:
use CodeEditor;
use Theme;
let mut source = use_signal;
rsx!
It is controlled — drive value from your own signal and update it inside oninput.
Themes
Thirty-odd built-ins, including Tokyo Night, Catppuccin (all four), Dracula, GitHub Light/Dark, Gruvbox, Nord, One Dark, Rosé Pine, Solarized, the Rustdoc themes, and others. Each is exposed as a Theme constant and a CSS asset; pages with multiple themes render side-by-side without leaking styles.
Code
Examples
Workspace layout
| crate | purpose |
|---|---|
dioxus-code |
The Code component, themes, and runtime/macro entry points. |
dioxus-code-editor |
Editable code surface built on Code. |
dioxus-code-macro |
Implementation of code!(). Re-exported by dioxus-code under the macro feature. |
License
MIT. See the repository LICENSE file.