Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs

Framework guide: Dioxus

Rust components for Dioxus 0.7 that render the same markup and stylesheet as the React adapter on web, desktop, mobile, and Dioxus Native.

Language
Rust
Dioxus
0.7
Components
239

Lumen 6 introduces the stable lumen-dioxus 6.0 release line, which shares the Lumen major. The setup below follows the current release contract; check crates.io for publication before installing. Existing experimental consumers should rename ToggleProps to CheckboxProps and replace CardVariant::Glass with the glass prop. See the v6 migration guide.

Installation

Add lumen-dioxus from crates.io. Your app picks its renderer through the features of its own dioxus dependency; the crate itself only uses Dioxus components, signals, and hooks.

Cargo

bash
cargo add lumen-dioxus

Or edit Cargo.toml

toml
[dependencies]
dioxus = { version = "0.7", features = ["web"] }
lumen-dioxus = "6.0"

Quick start

Import the prelude, render LumenStyles once near the root, and compose components. LumenStyles embeds the complete Lumen stylesheet in a <style> element; if you load styles another way, lumen_dioxus::LUMEN_CSS holds the same CSS as a string.

rustsrc/main.rs
Show full exampleCollapse example37 lines
use dioxus::prelude::*;
use lumen_dioxus::prelude::*;

fn main() {
    dioxus::launch(App);
}

#[component]
fn App() -> Element {
    let mut notifications = use_signal(|| true);

    rsx! {
        LumenStyles {}
        LumenTheme {
            Card {
                CardHeader {
                    CardTitle { "Workspace plan" }
                    CardDescription { "Shared libraries and audit logs." }
                }
                CardContent {
                    label {
                        Switch {
                            checked: notifications(),
                            onchange: move |next| notifications.set(next),
                            aria_label: "Notifications",
                        }
                        "Notifications"
                    }
                }
                CardFooter {
                    Button { variant: ButtonVariant::Secondary, "Compare plans" }
                    Button { onclick: move |_| {}, "Upgrade" }
                }
            }
        }
    }
}
use dioxus::prelude::*;
use lumen_dioxus::prelude::*;

fn main() {
    dioxus::launch(App);
}

#[component]
fn App() -> Element {
    let mut notifications = use_signal(|| true);

    rsx! {

Components render the same classes and attributes as the React adapter, so Lumen CSS styles them the same way. Every component also accepts class, appended after the Lumen classes, and any attribute its HTML element accepts, such as id, aria_label, or r#for.

Renderers

Choose a renderer with the dioxus features in your app’s Cargo.toml. Web and mobile builds use the Dioxus CLI: install it with cargo install dioxus-cli and keep it on the same 0.7 release line as your dioxus dependency.

Dioxus renderers, their feature flags, and run commands
Rendererdioxus featuresRun your appCrate example
WebBrowsers, compiled to WebAssembly["web"]dx serve --platform webdx serve --example web --features web-example --platform web
DesktopmacOS, Windows, and Linux in the system webview["desktop"]dx serve --platform desktopcargo run --example desktop --features desktop-example
MobileiOS and Android in the system webview["mobile"]dx serve --platform iosdx serve --platform androidNo mobile example yet
Dioxus NativeNative windows drawn by the Blitz engine, without a webview["native"]cargo runcargo run --example gallery --features native-example
Server renderingHTML strings for servers and static sites["ssr"]cargo runcargo run --example ssr > lumen.html

Render on the server

With the ssr feature, dioxus::ssr renders Lumen components to an HTML string for servers and static sites. Include LumenStyles in the rendered tree, or serve LUMEN_CSS as a stylesheet.

rust
use dioxus::prelude::*;
use lumen_dioxus::prelude::*;

fn main() {
    let html = dioxus::ssr::render_element(rsx! {
        LumenStyles {}
        Button { "Upgrade" }
    });

    println!("{html}");
}

Theming

LumenTheme applies a color scheme and an appearance preset to its children and paints the canvas, text color, and font. It sets the same data-theme, data-lumen-scheme, and data-lumen-preset attributes the other adapters set on <html>, so it works on every renderer, including Dioxus Native. Wrap the whole app, or nest it to theme one section.

rust
use dioxus::prelude::*;
use lumen_dioxus::prelude::*;

#[component]
fn App() -> Element {
    let mut scheme = use_signal(|| LumenScheme::Light);

    rsx! {
        LumenStyles {}
        LumenTheme { scheme: scheme(), preset: LumenPreset::Paper,
            Button { onclick: move |_| scheme.set(scheme().toggled()), "Toggle dark mode" }

            // Nest a theme to style one section differently.
            LumenTheme { scheme: LumenScheme::Dark, preset: LumenPreset::Voltage,
                Card { CardContent { "Always dark" } }
            }
        }
    }
}

LumenScheme is Light or Dark, and toggled() flips it. Every LumenPreset has light and dark variants:

  • LumenPreset::Default
  • LumenPreset::Classic
  • LumenPreset::Paper
  • LumenPreset::Luminous
  • LumenPreset::Voltage
  • LumenPreset::Signal
  • LumenPreset::Studio
  • LumenPreset::Aura

LumenPreset::Default uses the v6 cool neutrals, graphite actions, violet emphasis and Inter. Choose LumenPreset::Classic for the earlier warm palette and Montserrat, or LumenPreset::Studio for dense, quiet surfaces in editors, consoles and admin tools. LumenStyles embeds the default font bytes with its CSS. Compare the presets in the theme playground.

Icons

Icon draws inline SVG that follows the text color. Pass a constant from icons::lucide so only the icons you use reach the binary, or resolve a name from the Lumen icon catalog at runtime. Give meaningful icons a label; unnamed icons are decorative.

rust
rsx! {
    // A constant keeps only the icons you use in the binary.
    Icon { icon: &icons::lucide::TRASH, label: "Delete" }
    // A name resolves at runtime from the full Lucide catalog.
    Icon { name: "trash", size: IconSize::Lg }
    // Brand icons need the brand-icons feature.
    Icon { name: "brand:github", label: "GitHub" }
}

Brand icons (Font Awesome Free, CC BY 4.0) are behind the brand-icons feature. Enable it to use icons::brand constants and brand: names:

tomlCargo.toml
[dependencies]
lumen-dioxus = { version = "6.0", features = ["brand-icons"] }

Component coverage

lumen-dioxus exports a component for each of the Lumen registry’s components, 239 in all, with the same names as the React adapter. Each name links to its component page for behavior, props, and accessibility guidance. Pages marked Rust example (239 so far) include a compiled Dioxus tab in their code example.

Actions 9

AI 8

Brand 4

Data display 80

Feedback 13

Forms 42

Interaction 2

Layout 38

Navigation 24

Overlays 19

Dioxus Native support and limits

Dioxus Native draws HTML and CSS with the Blitz engine instead of a webview. The components keep one markup contract across renderers, so a few behaviors follow what Blitz supports today.

Events and focus
Dioxus Native reports click, mouse, keyboard, and input events, but no pointer, hover, scroll, wheel, resize, double-click, submit, or mounted events yet. Hover cards and tooltips open on click, focus, or a controlled open prop; drags use mouse events; scroll-linked components take controlled values; and roving focus updates the tab stop without moving DOM focus.
SVG icons and charts
Blitz draws inline SVG as an image, so Lumen CSS does not reach it: icons and chart marks keep their default colors and cannot be clicked. Chart legends, data tables, and the HTML-based charts work fully.
Checkbox and Switch
Checkbox and Switch render as <button role="checkbox"> and <button role="switch"> with aria-checked on every renderer, because Blitz ignores appearance: none on native inputs. A named, checked control also renders a hidden input, so forms still submit its value.
Placeholders
Input and Textarea placeholders do not show on Dioxus Native yet. Keep a visible Label on every field.
Glass
Glass surfaces need backdrop-filter, which Dioxus Native draws only with its Skia renderer.
Brand gradients
The Aura brand gradient is a plain three-stop linear-gradient layered over the solid brand color, and the glow elevation is made of box shadows. Dioxus Native draws both; a renderer that cannot draw the gradient shows the solid brand color.
Floating panels
Dialogs, popovers, menus, and other floating panels stay in the component tree instead of the browser top layer, placed by Lumen CSS. A transparent dismiss layer closes them on an outside click, and Escape closes them from the focused panel.
Web-only APIs
Clipboard access, scroll observers, contenteditable editing, and Rive animations run through dioxus::document::eval in browsers and webviews. Dioxus Native has no JavaScript engine, so those enhancements are skipped there.

The crate README tracks the current Blitz gaps as Dioxus Native support grows.

Examples

The crate ships a component gallery for each renderer and a server-rendering example. Run them from packages/dioxus in a clone of the repository. Every Dioxus example on this site compiles as a crate test, so it stays in step with the crate API.

bash
git clone https://github.com/santi020k/lumen.git
cd lumen/packages/dioxus

# Every component on Dioxus Native
cargo run --example gallery --features native-example

# The same gallery in a desktop webview
cargo run --example desktop --features desktop-example

# The same gallery in the browser (needs the Dioxus CLI)
dx serve --example web --features web-example --platform web

# A Lumen page rendered to an HTML file
cargo run --example ssr > lumen.html

Versioning and MSRV

  • lumen-dioxus shares the Lumen major with every published package and follows semantic versioning within it. lumen-dioxus = "6.0" accepts every compatible 6.x release.
  • It requires Dioxus 0.7.10 or a later 0.7 release.
  • The minimum supported Rust version is 1.88, and the crate uses the 2024 edition.
  • Parity tests render each component with Dioxus SSR and compare it with the React adapter’s markup.

docs.rs

API reference for every component, prop, and option enum.

crates.io

Published versions, features, and download statistics.

Crate README

The crate README, examples, and renderer notes on GitHub.

Web docsFull catalog