agentleFS
adxptivedadxptived/Rust-Skills/skills/rust-dioxus/SKILL.md

rust-dioxus

Skill1 starsChanged 6 months agoMITView on GitHub

Dioxus — cross-platform UI framework for Rust (web, desktop, mobile, SSR). Use this skill when: - User builds a web app, desktop app, or mobile app with Dioxus - User asks about Dioxus components, props, or RSX syntax - User works with Dioxus signals, state management, or reactivity - User uses use_signal, use_resource, use_effect, or use_memo - User implements routing with Dioxus Router - User asks about Dioxus full-stack (server functions, SSR) - User targets web (WASM), desktop (native), or mobile with Dioxus - User encounters Dioxus-specific compilation errors or rendering issues

  • Installs packages

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Attributes: Write HTML/SVG attributes inline.

    line 70
  2. Very specific:

    Element keys: Always specify a key attribute when rendering dynamic lists inside loops.

    line 71
  3. Very specific:

    Use use_memo to cache computations and prevent wasteful recalculations when dependencies haven't changed.

    line 105
  4. Very specific:

    Use use_resource to run async fetching routines.

    line 133
  5. Distinctive:

    Ensure you configure Window preferences elegantly on desktop launches:

    line 167
  6. Distinctive:

    Keep component logic in pure functions or hooks so behavior can be tested without a browser.

    line 186
  7. Distinctive:

    Keep signals scoped to the smallest component that needs them.

    line 205
  8. Very specific:

    Avoid cloning large values into rsx!

    line 206
  9. Distinctive:

    Use memoization for expensive derived state.

    line 207
  10. Distinctive:

    Avoid blocking work in event handlers.

    line 208
  11. Distinctive:

    Keep signals scoped near their consumers.

    line 246
  12. Distinctive:

    Avoid sync IO and CPU-heavy work in UI event handlers.

    line 248
  13. Distinctive:

    Test core state transitions separately from rendering when possible.

    line 251

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Quick Navigation

  • references/signals_reactivity.md
  • references/fullstack_ssr.md

Dioxus Cross-Platform UI Framework

A comprehensive guide to building beautiful, performant, and reactive user interfaces in Rust targeting WASM, Native Desktop, Mobile, and Server-Side Rendering (SSR).

Quick Setup & Ecosystem

# Install the cargo helper utility
cargo install dioxus-cli

# Initialize a project template
dx new my-app --template fullstack
dx serve
# Cargo.toml
[dependencies]
dioxus = { version = "0.6", features = ["web"] } # or "desktop", "fullstack"

Component Architecture & RSX Syntax

Dioxus components are regular functions annotated with #[component] returning an Element:

use dioxus::prelude::*;

#[component]
pub fn App() -> Element {
    rsx! {
        div {
            class: "app-container",
            Header { title: "Dioxus Dashboard" }
            MainContent {}
        }
    }
}

#[component]
fn Header(title: String) -> Element {
    rsx! {
        header { class: "nav-header", h1 { "{title}" } }
    }
}

Key RSX Constraints

  • Attributes: Write HTML/SVG attributes inline. Class names should use CSS names or utility framework classes (e.g. Tailwind).
  • Element keys: Always specify a key attribute when rendering dynamic lists inside loops.
rsx! {
    ul {
        for user in users.read().iter() {
            li { key: "{user.id}", "{user.name}" }
        }
    }
}

Reactivity & State Management (Dioxus 0.6)

Dioxus handles state tracking automatically via thread-safe Signals.

Local Component State

#[component]
fn Counter() -> Element {
    let mut count = use_signal(|| 0);

    rsx! {
        button {
            onclick: move |_| count += 1, // Mutates value and triggers re-render
            "Count: {count}"
        }
    }
}

Derived State: Memoization

Use use_memo to cache computations and prevent wasteful recalculations when dependencies haven't changed.

let value = use_signal(|| 10);
let doubled = use_memo(move || value() * 2);

Global Shared Context

Provide and consume structured context globally down the virtual DOM tree without prop-drilling.

#[derive(Clone, Copy)]
struct AppState {
    authenticated: Signal<bool>,
}

// Parent Component
use_context_provider(|| AppState {
    authenticated: Signal::new(false),
});

// Child Component
let state = use_context::<AppState>();

Async Resources & Server Integration

Use use_resource to run async fetching routines.

let posts = use_resource(move || async move {
    reqwest::get("https://api.example.com/posts")
        .await?
        .json::<Vec<Post>>()
        .await
});

match &*posts.read_unchecked() {
    None => rsx! { "Loading..." },
    Some(Err(e)) => rsx! { "Error: {e}" },
    Some(Ok(list)) => rsx! {
        for post in list {
            p { "{post.title}" }
        }
    }
}

Server Functions (Full-Stack)

Define APIs that compile to RPC endpoints automatically.

#[server(GetDatabaseStats)]
pub async fn get_stats() -> Result<Stats, ServerFnError> {
    // This code executes purely on the backend server
    Ok(db::fetch_stats().await?)
}

Desktop-Specific Invariants

Ensure you configure Window preferences elegantly on desktop launches:

fn main() {
    dioxus::LaunchBuilder::desktop()
        .with_cfg(
            dioxus::desktop::Config::default()
                .with_window(
                    dioxus::desktop::WindowBuilder::new()
                        .with_title("App")
                        .with_inner_size(dioxus::desktop::LogicalSize::new(1280, 720))
                )
        )
        .launch(App);
}

Testing Components

Keep component logic in pure functions or hooks so behavior can be tested without a browser.

fn format_count(count: i32) -> String {
    match count {
        0 => "No items".to_string(),
        1 => "1 item".to_string(),
        n => format!("{n} items"),
    }
}

#[test]
fn formats_count() {
    assert_eq!(format_count(2), "2 items");
}

Performance Guidelines

  • Keep signals scoped to the smallest component that needs them.
  • Avoid cloning large values into rsx!; pass IDs or Arc when appropriate.
  • Use memoization for expensive derived state.
  • Avoid blocking work in event handlers; use async tasks or server functions.
  • Split large pages into components so rerenders stay localized.
let filtered = use_memo(move || {
    let query = query.read().to_lowercase();
    items.read()
        .iter()
        .filter(|item| item.name.to_lowercase().contains(&query))
        .cloned()
        .collect::<Vec<_>>()
});

Error Handling

Represent loading, error, and success states explicitly. Do not unwrap in render paths.

#[derive(Clone)]
enum LoadState<T> {
    Idle,
    Loading,
    Loaded(T),
    Failed(String),
}

Anti-Patterns

  • Storing all app state in one global signal.
  • Performing network requests directly in render logic.
  • Blocking desktop event handlers with sync IO.
  • Passing large owned props through many layers when context or IDs would be clearer.
  • Mixing server-only APIs into client components without feature gates.

Production Checklist

  • Keep signals scoped near their consumers.
  • Represent async resource states explicitly: loading, loaded, empty, failed.
  • Avoid sync IO and CPU-heavy work in UI event handlers.
  • Feature-gate server-only code and browser-only APIs.
  • Split large views into components to limit rerender blast radius.
  • Test core state transitions separately from rendering when possible.

References

  • Dioxus official documentation
  • Dioxus examples repository
  • Rust async and Tokio documentation for background task patterns

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.