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
In this repository24 other files it gives its agents.
- rust-api-designSkill
- rust-asyncSkill
- rust-axumSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-concurrencySkill
- rust-databaseSkill
- rust-ecosystemSkill
- rust-embeddedSkill
- rust-error-handlingSkill
- rust-fintechSkill
- rust-masterySkill
- rust-memory-optimizationSkill
- rust-mlSkill
- rust-networkingSkill
- rust-observabilitySkill
- rust-ownershipSkill
- rust-design-patternsSkill
- rust-performanceSkill
- rust-securitySkill
- rust-testingSkill
- rust-type-systemSkill
- rust-unsafeSkill
- rust-wasmSkill
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
- Distinctive: line 70
Attributes: Write HTML/SVG attributes inline.
- Very specific: line 71
Element keys: Always specify a key attribute when rendering dynamic lists inside loops.
- Very specific: line 105
Use use_memo to cache computations and prevent wasteful recalculations when dependencies haven't changed.
- Very specific: line 133
Use use_resource to run async fetching routines.
- Distinctive: line 167
Ensure you configure Window preferences elegantly on desktop launches:
- Distinctive: line 186
Keep component logic in pure functions or hooks so behavior can be tested without a browser.
- Distinctive: line 205
Keep signals scoped to the smallest component that needs them.
- Very specific: line 206
Avoid cloning large values into rsx!
- Distinctive: line 207
Use memoization for expensive derived state.
- Distinctive: line 208
Avoid blocking work in event handlers.
- Distinctive: line 246
Keep signals scoped near their consumers.
- Distinctive: line 248
Avoid sync IO and CPU-heavy work in UI event handlers.
- Distinctive: line 251
Test core state transitions separately from rendering when possible.
≈ “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.
Files
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
keyattribute 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 orArcwhen 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
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
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.

