Skip to main content

Code

Function Code 

Source
pub fn Code(props: CodeProps) -> Element
Expand description

Render syntax-highlighted source code.

Pair the code! macro for compile-time parsing, or SourceCode for runtime parsing with the runtime feature. The component injects its own stylesheet plus the selected theme’s stylesheet.

use dioxus::prelude::*;
use dioxus_code::{Code, Theme, code};

fn _example() -> Element {
    rsx! {
        Code { src: code!("/snippets/demo.rs"), theme: Theme::TOKYO_NIGHT }
    }
}