Convert Figma logo to code with AI

DioxusLabs logodioxus

Fullstack app framework for web, desktop, and mobile.

30,719
1,295
30,719
477

Top Related Projects

31,806

Rust / Wasm framework for creating reliable and efficient web applications

18,846

Build fast web applications with Rust.

27,771

A cross-platform GUI library for Rust, inspired by Elm

26,011

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native

4,637

A Text User Interface library for the Rust programming language

Quick Overview

Dioxus is a portable, performant, and ergonomic framework for building cross-platform user interfaces in Rust. It allows developers to create reactive and efficient applications that can run on web browsers, desktop, and mobile platforms using a single codebase.

Pros

  • Cross-platform development with a single Rust codebase
  • Reactive and efficient UI rendering
  • Strong type safety and performance benefits of Rust
  • Growing ecosystem with official and community-driven tools and components

Cons

  • Relatively new project, still evolving and stabilizing
  • Smaller community compared to more established UI frameworks
  • Learning curve for developers new to Rust or reactive programming
  • Limited documentation and examples compared to mature frameworks

Code Examples

  1. Creating a simple component:
use dioxus::prelude::*;

fn App(cx: Scope) -> Element {
    cx.render(rsx! {
        div {
            h1 { "Hello, Dioxus!" }
            p { "Welcome to my first Dioxus app." }
        }
    })
}
  1. Using state in a component:
use dioxus::prelude::*;

fn Counter(cx: Scope) -> Element {
    let mut count = use_state(cx, || 0);
    cx.render(rsx! {
        div {
            h2 { "Counter: {count}" }
            button { onclick: move |_| count += 1, "Increment" }
        }
    })
}
  1. Handling user input:
use dioxus::prelude::*;

fn NameInput(cx: Scope) -> Element {
    let mut name = use_state(cx, String::new);
    cx.render(rsx! {
        div {
            input {
                value: "{name}",
                oninput: move |evt| name.set(evt.value.clone()),
            }
            p { "Hello, {name}!" }
        }
    })
}

Getting Started

To start using Dioxus, follow these steps:

  1. Install Rust and Cargo (if not already installed)
  2. Add Dioxus to your project:
    cargo add dioxus
    
  3. For web development, install the Dioxus CLI:
    cargo install dioxus-cli
    
  4. Create a new Dioxus project:
    dioxus create my_app
    cd my_app
    
  5. Run your app in development mode:
    dioxus serve
    

This will start a development server, and you can view your app in a web browser at http://localhost:8080.

Competitor Comparisons

31,806

Rust / Wasm framework for creating reliable and efficient web applications

Pros of Yew

  • More mature and established project with a larger community
  • Extensive documentation and examples available
  • Better integration with existing JavaScript libraries and frameworks

Cons of Yew

  • Steeper learning curve, especially for developers new to Rust
  • Larger bundle sizes compared to Dioxus
  • Slower compilation times due to its macro-heavy approach

Code Comparison

Yew:

use yew::prelude::*;

#[function_component(App)]
fn app() -> Html {
    html! { <h1>{"Hello, World!"}</h1> }
}

Dioxus:

use dioxus::prelude::*;

fn app(cx: Scope) -> Element {
    cx.render(rsx! { h1 { "Hello, World!" } })
}

Both Yew and Dioxus are Rust frameworks for building web applications, but they have different approaches and trade-offs. Yew offers a more React-like experience with its JSX-style syntax, while Dioxus aims for a more lightweight and performant solution. The code comparison shows that Dioxus has a slightly more concise syntax, which may be easier for some developers to read and write. However, Yew's syntax might feel more familiar to those coming from a React background.

18,846

Build fast web applications with Rust.

Pros of Leptos

  • Fine-grained reactivity system for efficient updates
  • Server-side rendering with hydration support
  • Integrated routing capabilities

Cons of Leptos

  • Smaller community and ecosystem compared to Dioxus
  • Less comprehensive documentation and learning resources
  • Fewer built-in components and utilities

Code Comparison

Leptos:

#[component]
fn App() -> impl IntoView {
    let (count, set_count) = create_signal(0);
    view! {
        <button on:click=move |_| set_count.update(|n| *n + 1)>
            "Click me: " {count}
        </button>
    }
}

Dioxus:

fn App(cx: Scope) -> Element {
    let (count, set_count) = use_state(cx, || 0);
    cx.render(rsx! {
        button { onclick: move |_| set_count(count + 1),
            "Click me: {count}"
        }
    })
}

Both Leptos and Dioxus are Rust frameworks for building web applications. Leptos offers a more reactive approach with fine-grained updates, while Dioxus provides a larger ecosystem and more comprehensive documentation. The code comparison shows similar syntax for creating components and handling state, with Leptos using a more declarative view! macro and Dioxus utilizing the rsx! macro for rendering.

27,771

A cross-platform GUI library for Rust, inspired by Elm

Pros of iced

  • More mature and stable project with a larger community
  • Supports multiple backends (Vulkan, Metal, OpenGL, WebGL)
  • Provides a native look and feel on different platforms

Cons of iced

  • Steeper learning curve due to its more complex architecture
  • Less flexible for web development compared to Dioxus
  • Limited support for custom styling and theming

Code Comparison

iced:

use iced::{button, Button, Column, Element, Sandbox, Settings, Text};

struct Counter {
    value: i32,
    increment_button: button::State,
    decrement_button: button::State,
}

Dioxus:

use dioxus::prelude::*;

fn app(cx: Scope) -> Element {
    let mut count = use_state(cx, || 0);
    cx.render(rsx!{
        button { onclick: move |_| count += 1, "Increment" }
    })
}

The iced example shows a more verbose approach with explicit state management, while Dioxus demonstrates a more concise, React-like syntax with hooks for state management. Iced's code structure reflects its focus on native GUI development, whereas Dioxus's syntax is optimized for web-like interfaces.

26,011

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native

Pros of egui

  • Immediate mode GUI, offering simplicity and performance benefits
  • Lightweight and easy to integrate into existing Rust projects
  • Supports both 2D and 3D rendering

Cons of egui

  • Less feature-rich compared to retained mode GUIs
  • Limited styling options and customization
  • Steeper learning curve for developers used to traditional GUI frameworks

Code Comparison

egui:

ui.heading("My egui Application");
ui.horizontal(|ui| {
    ui.label("Your name: ");
    ui.text_edit_singleline(&mut name);
});

Dioxus:

rsx! {
    h1 { "My Dioxus Application" }
    div {
        label { "Your name: " }
        input { value: name, oninput: move |evt| name.set(evt.value.clone()) }
    }
}

Both frameworks aim to simplify GUI development in Rust, but they take different approaches. egui focuses on immediate mode rendering, which can be more performant but may require more manual control. Dioxus, on the other hand, provides a more familiar declarative syntax similar to React, which may be easier for web developers to adopt. The choice between the two depends on the specific project requirements and developer preferences.

4,637

A Text User Interface library for the Rust programming language

Pros of Cursive

  • Mature and stable TUI library with a rich set of widgets
  • Simpler learning curve for developers familiar with traditional UI frameworks
  • Better suited for terminal-based applications and environments without graphical capabilities

Cons of Cursive

  • Limited to terminal interfaces, lacking the flexibility of web-based UIs
  • Less modern and potentially less performant compared to Dioxus' reactive approach
  • Smaller community and ecosystem compared to web-focused frameworks

Code Comparison

Cursive example:

siv.add_layer(
    Dialog::around(
        EditView::new()
            .on_submit(|s, name| {
                s.pop_layer();
                s.add_layer(Dialog::text(format!("Hello {}!", name)));
            })
            .fixed_width(20),
    )
    .title("Enter your name"),
);

Dioxus example:

rsx! {
    div {
        input {
            oninput: move |evt| set_name(evt.value.clone()),
            value: "{name}",
        }
        button { onclick: move |_| set_greeting(format!("Hello, {name}!")),
            "Greet"
        }
        p { "{greeting}" }
    }
}

Both libraries offer different approaches to UI development in Rust, with Cursive focusing on terminal interfaces and Dioxus targeting web and cross-platform applications. The choice between them depends on the specific project requirements and target environment.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README



✨ Dioxus 0.7 is in alpha - test it out! ✨


Build for web, desktop, and mobile, and more with a single codebase. Zero-config setup, integrated hot-reloading, and signals-based state management. Add backend functionality with Server Functions and bundle with our CLI.

fn app() -> Element {
    let mut count = use_signal(|| 0);

    rsx! {
        h1 { "High-Five counter: {count}" }
        button { onclick: move |_| count += 1, "Up high!" }
        button { onclick: move |_| count -= 1, "Down low!" }
    }
}

⭐️ Unique features:

  • Cross-platform apps in three lines of code (web, desktop, mobile, server, and more)
  • Ergonomic state management combines the best of React, Solid, and Svelte
  • Built-in featureful, type-safe, fullstack web framework
  • Integrated bundler for deploying to the web, macOS, Linux, and Windows
  • Subsecond Rust hot-patching and asset hot-reloading
  • And more! Take a tour of Dioxus.

Instant hot-reloading

With one command, dx serve and your app is running. Edit your markup, styles, and see changes in milliseconds. Use our experimental dx serve --hotpatch to update Rust code in real time.

Build Beautiful Apps

Dioxus apps are styled with HTML and CSS. Use the built-in TailwindCSS support or load your favorite CSS library. Easily call into native code (objective-c, JNI, Web-Sys) for a perfect native touch.

Truly fullstack applications

Dioxus deeply integrates with axum to provide powerful fullstack capabilities for both clients and servers. Pick from a wide array of built-in batteries like WebSockets, SSE, Streaming, File Upload/Download, Server-Side-Rendering, Forms, Middleware, and Hot-Reload, or go fully custom and integrate your existing axum backend.

Experimental Native Renderer

Render using web-sys, webview, server-side-rendering, liveview, or even with our experimental WGPU-based renderer. Embed Dioxus in Bevy, WGPU, or even run on embedded Linux!

First-party primitive components

Get started quickly with a complete set of primitives modeled after shadcn/ui and Radix-Primitives.

First-class Android and iOS support

Dioxus is the fastest way to build native mobile apps with Rust. Simply run dx serve --platform android and your app is running in an emulator or on device in seconds. Call directly into JNI and Native APIs.

Bundle for web, desktop, and mobile

Simply run dx bundle and your app will be built and bundled with maximization optimizations. On the web, take advantage of .avif generation, .wasm compression, minification, and more. Build WebApps weighing less than 50kb and desktop/mobile apps less than 5mb.

Fantastic documentation

We've put a ton of effort into building clean, readable, and comprehensive documentation. All html elements and listeners are documented with MDN docs, and our Docs runs continuous integration with Dioxus itself to ensure that the docs are always up to date. Check out the Dioxus website for guides, references, recipes, and more. Fun fact: we use the Dioxus website as a testbed for new Dioxus features - check it out!

Modular and Customizable

Build your own renderer, or use a community renderer like Freya. Use our modular components like RSX, VirtualDom, Blitz, Taffy, and Subsecond.

Community

Dioxus is a community-driven project, with a very active Discord and GitHub community. We're always looking for help, and we're happy to answer questions and help you get started. Our SDK is community-run and we even have a GitHub organization for the best Dioxus crates that receive free upgrades and support.

Full-time core team

Dioxus has grown from a side project to a small team of fulltime engineers. Thanks to the generous support of FutureWei, Satellite.im, the GitHub Accelerator program, we're able to work on Dioxus full-time. Our long term goal is for Dioxus to become self-sustaining by providing paid high-quality enterprise tools. If your company is interested in adopting Dioxus and would like to work with us, please reach out!

Supported Platforms

Web
  • Render directly to the DOM using WebAssembly
  • Pre-render with SSR and rehydrate on the client
  • Simple "hello world" at about 50kb, comparable to React
  • Built-in dev server and hot reloading for quick iteration
Desktop
  • Render using Webview or - experimentally - with WGPU or Freya (Skia)
  • Zero-config setup. Simply `cargo run` or `dx serve` to build your app
  • Full support for native system access without IPC
  • Supports macOS, Linux, and Windows. Portable <3mb binaries
Mobile
  • Render using Webview or - experimentally - with WGPU or Skia
  • Build .ipa and .apk files for iOS and Android
  • Call directly into Java and Objective-C with minimal overhead
  • From "hello world" to running on device in seconds
Server-side Rendering
  • Suspense, hydration, and server-side rendering
  • Quickly drop in backend functionality with server functions
  • Extractors, middleware, and routing integrations
  • Static-site generation and incremental regeneration

Running the examples

The examples in the main branch of this repository target the git version of dioxus and the CLI. If you are looking for examples that work with the latest stable release of dioxus, check out the 0.6 branch.

The examples in the top level of this repository can be run with:

cargo run --example <example>

However, we encourage you to download the dioxus-cli to test out features like hot-reloading. To install the most recent binary CLI, you can use cargo binstall.

cargo binstall dioxus-cli@0.7.0-rc.0 --force

If this CLI is out-of-date, you can install it directly from git

cargo install --git https://github.com/DioxusLabs/dioxus dioxus-cli --locked

With the CLI, you can also run examples with the web platform. You will need to disable the default desktop feature and enable the web feature with this command:

dx serve --example <example> --platform web -- --no-default-features

Contributing

License

This project is licensed under either the MIT license or the Apache-2 License.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Dioxus by you, shall be licensed as MIT or Apache-2, without any additional terms or conditions.