{"id":50425004,"url":"https://github.com/dioxuslabs/dioxus-code","last_synced_at":"2026-05-31T10:01:21.736Z","repository":{"id":355910635,"uuid":"1229984997","full_name":"DioxusLabs/dioxus-code","owner":"DioxusLabs","description":"Bundle size friendly code highlighting component for dioxus","archived":false,"fork":false,"pushed_at":"2026-05-26T14:21:01.000Z","size":17193,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-26T15:34:57.403Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dioxuslabs.github.io/dioxus-code/","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DioxusLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-05T15:08:45.000Z","updated_at":"2026-05-20T14:24:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/DioxusLabs/dioxus-code","commit_stats":null,"previous_names":["dioxuslabs/dioxus-code","ealmloff/dioxus-code"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/DioxusLabs/dioxus-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DioxusLabs%2Fdioxus-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DioxusLabs%2Fdioxus-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DioxusLabs%2Fdioxus-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DioxusLabs%2Fdioxus-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DioxusLabs","download_url":"https://codeload.github.com/DioxusLabs/dioxus-code/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DioxusLabs%2Fdioxus-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33726719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-31T10:01:16.173Z","updated_at":"2026-05-31T10:01:17.045Z","avatar_url":"https://github.com/DioxusLabs.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003edioxus-code\u003c/h1\u003e\n  \u003cp\u003e\u003cstrong\u003eSyntax-highlighted code blocks for Dioxus.\u003c/strong\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://crates.io/crates/dioxus-code\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/dioxus-code.svg?style=flat-square\" alt=\"Crates.io version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://crates.io/crates/dioxus-code\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/d/dioxus-code.svg?style=flat-square\" alt=\"Downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://docs.rs/dioxus-code\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\" alt=\"docs.rs\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n---\n\nA small Dioxus component for rendering source code with proper highlighting. Parsing is powered by [arborium](https://crates.io/crates/arborium); themes ship as scoped CSS so you can mix several on one page.\n\nTwo ways to highlight:\n\n- **[`code!`] macro** — parses at compile time and embeds the highlighted spans. Default.\n- **[`SourceCode`]** — parses at runtime. Opt in with the `runtime` feature for dynamic source text.\n\n## Quick start\n\n```toml\n[dependencies]\ndioxus-code = \"0.1\"\n```\n\n```rust\nuse dioxus::prelude::*;\nuse dioxus_code::{Code, Theme, code};\n\n#[component]\nfn ReadMe() -\u003e Element {\n    rsx! {\n        Code {\n            src: code!(\"/snippets/demo.rs\"),\n            theme: Theme::TOKYO_NIGHT,\n        }\n    }\n}\n```\n\nThe path is resolved from the consumer's `CARGO_MANIFEST_DIR`. `concat!` and `env!` work too.\nWhen the file extension is ambiguous, pass [`CodeOptions::builder`] with [`CodeOptions::with_language`].\n\n## Runtime highlighting\n\nFor editor-style use cases with dynamic source text:\n\n```toml\n[dependencies]\ndioxus-code = { version = \"0.1\", features = [\"runtime\"] }\n```\n\n```rust\n# use dioxus::prelude::*;\nuse dioxus_code::{Code, Language, SourceCode, Theme};\n# let user_input = String::new();\n# let _ =\nrsx! {\n    Code {\n        src: SourceCode::new(Language::Rust, user_input),\n        theme: Theme::GITHUB_LIGHT,\n    }\n}\n# ;\n```\n\nPass a [`Language`] variant when building [`SourceCode`]. The `runtime` feature includes Rust; enable the matching `lang-*` feature, or `all-languages`, for additional grammars.\n\n## Editor\n\n[`dioxus-code-editor`] is a sibling crate that pairs the highlighter with a textarea input layer:\n\n```rust\n# use dioxus::prelude::*;\nuse dioxus_code_editor::{CodeEditor, Language};\nuse dioxus_code::Theme;\n\n# fn editor() -\u003e Element {\nlet mut source = use_signal(|| String::new());\n\nrsx! {\n    CodeEditor {\n        value: source(),\n        language: Language::Rust,\n        theme: Theme::TOKYO_NIGHT,\n        oninput: move |value| source.set(value),\n    }\n}\n# }\n```\n\nIt is controlled — drive [`CodeEditorProps::value`] from your own signal and update it inside [`CodeEditorProps::oninput`].\n\n## Themes\n\nThirty-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; pages with multiple themes render side-by-side without leaking styles.\n\n```rust\n# use dioxus::prelude::*;\n# use dioxus_code::{Code, Theme, code};\n# let _ = rsx! {\nCode { src: code!(\"/snippets/demo.rs\"), theme: Theme::CATPPUCCIN_MOCHA }\n# };\n```\n\nUse [`CodeTheme::system`] to select a light and dark theme with CSS media\nqueries. This is JavaScript-free and works during SSR:\n\n```rust\n# use dioxus::prelude::*;\nuse dioxus_code::{Code, CodeTheme, Theme, code};\n\n# let _ = rsx! {\nCode {\n    src: code!(\"/snippets/demo.rs\"),\n    theme: CodeTheme::system(Theme::GITHUB_LIGHT, Theme::TOKYO_NIGHT),\n}\n# };\n```\n\n## Examples\n\n```sh\ndx serve --example dioxus-code-basic       # macro + runtime side by side\ndx serve --example dioxus-code-macro-only  # compile-time highlighted spans\ndx serve --example dioxus-code-live-input  # textarea bound to runtime highlighter\n```\n\n## Workspace layout\n\n| crate | purpose |\n|---|---|\n| [`dioxus-code`] | The [`Code`] component, themes, and runtime/macro entry points. |\n| [`dioxus-code-editor`] | Editable code surface built on [`Code`]. |\n| [`dioxus-code-macro`] | Implementation of [`code!`]. Re-exported by [`dioxus-code`] under the `macro` feature. |\n\n## License\n\nMIT. See the repository `LICENSE` file.\n\n[`code!`]: https://docs.rs/dioxus-code/latest/dioxus_code/macro.code.html\n[`Code`]: https://docs.rs/dioxus-code/latest/dioxus_code/fn.Code.html\n[`CodeEditorProps::oninput`]: https://docs.rs/dioxus-code-editor/latest/dioxus_code_editor/struct.CodeEditorProps.html#structfield.oninput\n[`CodeEditorProps::value`]: https://docs.rs/dioxus-code-editor/latest/dioxus_code_editor/struct.CodeEditorProps.html#structfield.value\n[`CodeOptions`]: https://docs.rs/dioxus-code/latest/dioxus_code/struct.CodeOptions.html\n[`CodeOptions::builder`]: https://docs.rs/dioxus-code/latest/dioxus_code/struct.CodeOptions.html#method.builder\n[`CodeOptions::with_language`]: https://docs.rs/dioxus-code/latest/dioxus_code/struct.CodeOptions.html#method.with_language\n[`CodeTheme::system`]: https://docs.rs/dioxus-code/latest/dioxus_code/struct.CodeTheme.html#method.system\n[`dioxus-code`]: https://crates.io/crates/dioxus-code\n[`dioxus-code-editor`]: https://crates.io/crates/dioxus-code-editor\n[`dioxus-code-macro`]: https://crates.io/crates/dioxus-code-macro\n[`SourceCode`]: https://docs.rs/dioxus-code/latest/dioxus_code/struct.SourceCode.html\n[`Theme`]: https://docs.rs/dioxus-code/latest/dioxus_code/struct.Theme.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdioxuslabs%2Fdioxus-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdioxuslabs%2Fdioxus-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdioxuslabs%2Fdioxus-code/lists"}