FerroUI: a cross-platform UI framework for Rust

FerroUI

18 min read Original article ↗

What is new in the release

Declarative, cross-platform UI in Rust

FerroUI is a cross-platform UI framework for Rust. An interface is written in declarative Rust: builders for every control, the rsx! macro, fine-grained signals and React-like components with hooks and a reconciler. It can also be written in XAML compiled to Rust. Both drive one control library with data binding, themes for five design languages and GPU rendering, on macOS, Windows, Linux, iOS, Android and the browser.

Get started Documentation Declarative UI GitHub

  • macOS
  • Windows
  • Linux X11
  • Wayland
  • Framebuffer
  • iOS
  • Android
  • Browser
The FerroUI Control Catalog with the WinUI 3 theme on Windows 11, in a window with the Mica backdrop: a navigation pane with the control categories and a home page of control cards

Cargo.toml

[dependencies]
ferroui-base = "={{version}}"

[dependencies.ferroui-view]
version = "={{version}}"
features = ["desktop"]

Declarative Rust

A component that runs again when its signal changes; the reconciler patches the text. From the README.

src/main.rsrust

use ferroui_base::layout::Orientation;
use ferroui_view::prelude::*;

#[component(rerender)]
fn Counter() -> Element {
    let count = use_signal(|| 0);
    rsx! {
        StackPanel { orientation: Orientation::Horizontal, spacing: 8.0,
            TextBlock { text: format!("Clicked {} times", count.get()) }
            Button { class: "accent", on_click: move |_| count.update(|c| *c += 1), "Click" }
        }
    }
}

fn main() {
    ferroui_view::launch(|| rsx! { Window { title: "Counter", Counter {} } });
}

Or XAML, compiled to Rust

The same controls, themes and bindings in markup, compiled by the build script of the crate. Rust and XAML views can be mixed in one application.

MainWindow.xamlxml

<Window xmlns="https://github.com/ferroui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Hello">
  <StackPanel Margin="16" Spacing="8">
    <TextBlock Text="{Binding Greeting}" />
    <Button Content="Click" Command="{Binding ClickCommand}" />
  </StackPanel>
</Window>

Declarative Rust UI

Signals and React-like components, in Rust

ferroui-view writes user interfaces in plain Rust, on the same controls, themes, styles and bindings as markup. A component can run once and let its properties follow signals, in the manner of SolidJS and Leptos, or run again when its state changes and let a reconciler patch the controls, in the manner of React. Components of both kinds are children of each other.

The counter of 7GUIs as a component that runs again: its state is a hook, the function runs again when the count changes, and the reconciler patches the text of the field. From samples/SevenGuis.

counter.rsrust

use ferroui_base::layout::Orientation;
use ferroui_view::prelude::*;

#[component(rerender)]
pub fn Counter() -> Element {
    let count = use_signal(|| 0);
    rsx! {
        StackPanel { orientation: Orientation::Horizontal, spacing: 8.0,
            TextBox { text: count.get().to_string(), is_read_only: true, width: 80.0 }
            Button { on_click: move |_| count.update(|c| *c += 1), "Count" }
        }
    }
}

Builders and rsx!

A builder for every control, generated from the sources of the controls, and the rsx! macro for the tree, with attached properties, text, conditions and loops. A misspelled or mistyped attribute is a compile error.

Fine-grained signals

Signals, memos and effects. A property follows a signal or a closure and updates without running anything else; values can be two-way, and keyed lists, conditions and computed children follow state (for_each, show, dynamic).

Components and hooks

Function components with use_signal, use_memo, use_effect, use_effect_with and use_hook; provide_context and use_context hand values to the components below.

A reconciler

Siblings are matched by key and by place, equal values are left alone, handlers are swapped in place, and keyed lists are reordered with the fewest moves. A component with comparable parameters is memoized by default.

Async data, errors, navigation

use_future with suspense for data that arrives later, error_boundary for a part of the window that fails without ending the application, and a router with routes and parameters.

Styles, themes and motion

Styles with XAML selectors, the theme variant and resources followed live, transitions and key-frame animations, popups and context menus as elements, and virtualized lists whose items are components.

Hot reload and an inspector

With the feature hot-reload, the literals of rsx! are edited while the application runs and state, focus and scroll positions stay. Debug builds report missing keys and runaway components, and Shift+F12 opens an inspector of the components.

For React developers

React concepts and their FerroUI counterparts
ReactFerroUI
JSXrsx!, or the builders
function component#[component(rerender)], or #[component] that runs once
useState, useReduceruse_signal (a Copy signal: get, set, update)
useEffectuse_effect_with(deps, ..) with on_cleanup; use_effect follows the signals it reads
useMemo, useCallbackuse_memo (follows signals, no dependency list); handlers need no memoizing
useContextprovide_context, use_context::<T>()
React.memo, keythe default for comparable parameters, key: ..
error boundaries, Suspense, React Routererror_boundary, use_future with suspense, router with route
Fast Refresh, React DevToolsthe feature hot-reload (literals), the inspector (Shift+F12)

The complete mapping, where the two behave alike and where they differ, and what React has that FerroUI does not have yet are in declarative-ui-react.md.

Compiled XAML

Or write the views in XAML, compiled to Rust

Markup is the second way to write an interface, on the same controls, themes and bindings. The build script of a crate compiles it to Rust source; it can also be loaded at run time. Rust components and XAML views can be placed inside each other.

Compiled, or loaded at run time

XAML documents are compiled to Rust by the build script of the crate, with the framework's markup extensions; the run-time loader reads the same markup, and XAML reloaded at run time keeps supported live components.

Compiled bindings

Compiled {x:Bind} and compiled bindings by default, with converters, multi-bindings, data validation and templates; reflection-style binding paths remain available.

Themes trimmed to the application

Themes are compiled XAML, and an application keeps only the units of its theme it uses. A code-only application names its theme in a build script of one statement.

Rust and XAML together

A component in XAML (ComponentHost, register_component), XAML in a component (use_xaml), and the data context of a view model in a component (use_data_context).

MVVM with ReactiveUI

ReactiveUI, DynamicData, Splat and Rx as crates of the workspace, with an integration of ReactiveUI with the controls; only the integration depends on the user interface, so view models are tested without a window.

Behaviors

Triggers and actions in markup: about 330 custom behaviors, input events, drag and drop, responsive classes and animations.

Framework

One framework, from the controls to the pixels

Controls, styling, binding, layout and rendering in Rust, released together as one set of crates at one version, whichever way the views are written.

Controls

One control library, with automation peers for the accessibility APIs of the platforms.

A complete control library

Buttons, text input, items controls with virtualization, menus, pickers, calendar, navigation, pages, dialogs, rich text, inking and media, on an object model of styled properties, routed events, layout, input, focus and gestures.

WinUI controls and composition

WinUI controls such as NavigationView, InfoBar and NumberBox; acrylic and Mica materials, Reveal, theme shadows and connected animations.

Rich text

RichTextBlock and RichEditBox with a text object model, RTF and the rich clipboard, and an input method connection on every platform.

TreeDataGrid

Hierarchical and tabular data in one virtualizing view, with sorting, selection, editing and drag and drop; a builder in ferroui-view behind a feature.

Charts

Cartesian and pie charts of LiveCharts2, with its measurement, paint and motion and live data, and simple line, area and bar charts beside them.

Media and 3D

Video playback, camera capture and QR analysis in crates of their own, and WPF-style 3D: Viewport3D and the Media3D scene model, drawn in Skia and Vello.

Localization

ProTranslate supplies translation bindings, live culture switching, right-to-left layout, calendars, region and measurement services, and generated typed catalogs.

Themes and rendering

Five design languages, drawn on the GPU.

Five themes

WinUI 3 (the default), Fluent, Material 3 Expressive, macOS 26 and Simple, each for every control, with light and dark variants, on a styling system of selectors, styles, control themes, resources and transitions.

GPU rendering

A compositor with a render loop on its own thread, dirty-region tracking, server-side visuals and composition animations. Skia renders through Graphite on Metal, Ganesh on OpenGL, ANGLE, WebGL and Vulkan, or in software; HarfBuzz shapes text.

Vello, experimental

An experimental Vello backend sits behind the same contracts as Skia, with CPU, hybrid and GPU modes, and is measured against Skia.

Custom effects

Effects on Visual.Effect as effect graphs and as runtime shaders on Skia and Vello, with a library of effects and page transitions.

Platforms, tools and size

One code base on the desktop, on mobile and in the browser.

Six platforms

macOS, Windows, Linux (X11, Wayland and the framebuffer), iOS, Android and the browser through WebAssembly; FerroUI content in a WinUI 3 window, and headless windows for tests.

Developer tools

F12 opens the trees, the properties and where their values come from, styles, layout and routed events; an MCP server and a Chrome DevTools endpoint are opt-in.

Designer Studio

A visual designer built on the framework: an artboard with synchronized XAML, layers, editable properties, layout tools, preview stages, prototype flows and keyframe animation.

Small and measured

Themes and type tables are trimmed to what an application uses, shipped builds abort instead of unwinding, and frame cost, start time and size are held by a local performance gate.

Safe Rust

The controls, markup, XAML and theme crates contain no unsafe code. It is confined to a small part of the object model core and to the rendering, text shaping, platform and interop backends.

Samples

See it run, in the browser or on your machine

The browser builds below are the same Rust applications as on the desktop, compiled to WebAssembly and drawn into a canvas.

Applications

Live demos, each in a repository of its own except the catalog.

The Control Catalog with the WinUI 3 theme on Windows 11: a navigation pane and a grid of control cards

DesktopBrowseriOSAndroid

Control Catalog

Every control on its own page, in the WinUI 3 theme. The same catalog runs on the desktop, on iOS, on Android and in the browser.

Live demo Source

Calculator in the Standard mode in the light and dark themes, and in the Scientific mode showing sin(30) = 0.5

DesktopBrowser

Calculator

Microsoft Calculator on FerroUI, with its original C++ calculation engine compiled unchanged, to WebAssembly in the browser. Standard, Scientific and Programmer modes.

Live demo Source

A Klondike deal of Ferro Solitaire in the browser, on a green table

DesktopBrowser

Solitaire

Klondike, FreeCell and Spider, with XAML pages, vector playing cards, animated card movement and timed dealing.

Live demo Source

Ember, a Hacker News reader, in the light desktop theme: the front page beside a story with its comments Ember, a Hacker News reader, in the dark desktop theme: the front page beside a story with its comments

DesktopBrowseriOSAndroid

Ember

An adaptive, offline-capable Hacker News reader in the WinUI 3 theme, with compiled XAML and composition animations.

Live demo Source

FerroDesign editing a mobile banking design in the browser: layers on the left, phone screens on the canvas, properties on the right

DesktopBrowser

FerroDesign

A native design editor on the Vello backend: pages and layers, an infinite canvas, vector networks, auto-layout, components and prototypes.

Live demo Source

In the repository

The declarative samples first. Run them from a clone of FerroUI with the command on each card.

Six of the 7GUIs tasks: CRUD, Circle Drawer, Counter, Temperature Converter, Flight Booker and Timer

7GUIs

The seven tasks of the 7GUIs benchmark, each in three styles of the declarative API: builders, rsx! and components with hooks.

cargo run -p seven-guis-crud-macros

Source

TodoMVC written with ferroui-view: a list of three todos, one completed, with the filters All, Active and Completed

TodoMVC

TodoMVC as components that run again, with their state in hooks, a keyed list, editing in place and the filters as routes of the router, in the WinUI 3 theme.

cargo run -p todo-mvc

Source

ViewGallery in the light theme variant: a colour spectrum beside a TreeDataGrid of programming languages ViewGallery in the dark theme variant: a colour spectrum beside a TreeDataGrid of programming languages

ViewGallery

The declarative API with styles, the theme variant and resources, transitions, a context menu, the colour picker and the TreeDataGrid.

cargo run -p view-gallery

Source

Designer Studio: an artboard with a dialog being designed, the layers on the left and the properties on the right

Designer Studio

A visual XAML designer built on FerroUI: an artboard with synchronized XAML, layers, properties, layout tools, preview stages and keyframe animation.

cargo run -p designer-studio

Docs Source

ReactiveDemo on macOS: a search for serde in a crate browser with the WinUI 3 theme

ReactiveDemo

The getting-started sample of ReactiveUI: a crates.io browser on the WinUI 3 theme, with a view model, commands and bindings.

cargo run -p reactive-demo

Source

Charts of the LiveCharts2 port: columns with a line, and stacked areas with a legend

LiveChartsDemo

Six charts in one compiled XAML view with live data: columns with a line, a doughnut, stacked areas, scatter, candlesticks and a gauge.

Pictured: the CartesianChart page of the Control Catalog, on the same chart controls.

cargo run -p livecharts-demo --features desktop --bin livecharts-demo

Source

WinUI Gallery

The pinned WinUI Gallery catalog, 126 pages and 350 sample definitions with their original XAML, and native examples for a subset of the pages.

cargo run -p winui-gallery --features desktop

Source

Get started

From cargo new to a window

FerroUI is a set of crates released together at one version. Name the same version for every FerroUI crate, or generate a project from one of the templates.

  1. Install the requirements

    • Rust 1.89 or later (the browser needs 1.93 or later).
    • The first build downloads a prebuilt Skia for the target, or builds it from source where no prebuilt binary matches (Vulkan on Windows), and builds HarfBuzz from source with a C++ compiler; it can take a while.
    What each platform needs
    PlatformNeeds
    macOSmacOS 11 or later and the Xcode command line tools (the platform compiles an Objective-C++ library).
    Windowsx64 or ARM64, the MSVC build tools; libclang for ANGLE (the default feature angle); the feature vulkan builds Skia from source. Hosting in WinUI 3 needs the Windows App SDK 1.6 runtime and its bootstrap library beside the executable.
    LinuxThe development packages of fontconfig and FreeType. The system libraries (Xlib, GTK, GLib, EGL, Vulkan, Wayland, xkbcommon, libinput, libdrm, libgbm) are opened at run time; none is linked.
    iOSXcode with the iOS SDK and the targets aarch64-apple-ios and aarch64-apple-ios-sim; an application is bundled without an Xcode project (scripts/ios/bundle.sh).
    AndroidThe Android SDK and NDK, stable Rust with the target aarch64-linux-android, API level 26 or later; packaged without Gradle (scripts/android/apk.sh).
    BrowserThe target wasm32-unknown-emscripten, Emscripten and the pinned wasm-bindgen command-line tool (scripts/browser/setup.sh installs them).
  2. Start from a template

    One command creates a project with its theme, its first window and its tests: with rsx! and hooks or with builders, in XAML with MVVM or code-behind, or as a cross-platform repository. The templates list them with their options.

    Terminalsh

    cargo install cargo-generate
    cargo generate --git https://github.com/FerroUI/templates rsx --name my-app
  3. Or add the crates yourself

    A declarative desktop application names the base library, ferroui-view with its feature desktop, and a theme:

    Cargo.tomltoml

    [dependencies]
    ferroui-base = "={{version}}"
    ferroui-view = { version = "={{version}}", features = ["desktop"] }
    ferroui-themes-winui = "={{version}}"

    The WinUI 3 theme, ferroui-themes-winui (WinUITheme), is the default; the Fluent theme is ferroui-themes-fluent (FluentTheme), in place of WinUI 3 or beside it. An application in XAML or with Rust objects names the controls, ferroui-controls, and the desktop entry point, ferroui-desktop, as the examples below do. One dependency can stand for all of them: the facade crate ferroui, with a prelude and features for the platforms, the themes and the backends. MVVM is ferroui-reactiveui-controls and the developer tools are ferroui-diagnostics.

  4. Write a window

    Hello, World! in the WinUI 3 theme: with rsx! and a signal, in XAML, and with Rust objects.

    A component with a button that counts its clicks; the count is a signal that the text of the button follows. From samples/HelloWorld.Macros.

    Cargo.tomltoml

    [dependencies]
    ferroui-base = "={{version}}"
    ferroui-view = { version = "={{version}}", features = ["desktop"] }
    ferroui-themes-winui = "={{version}}"

    Terminalsh

    cargo new hello-ferroui
    cd hello-ferroui
    cargo run

    src/main.rsrust

    use ferroui_base::layout::{HorizontalAlignment, VerticalAlignment};
    use ferroui_view::prelude::*;
    
    /// The content of the window.
    #[component]
    fn Hello() -> Element {
        let clicks = signal(0);
        rsx! {
            StackPanel { horizontal_alignment: HorizontalAlignment::Center, vertical_alignment: VerticalAlignment::Center, spacing: 12.0,
                TextBlock { text: "Hello, World!", font_size: 28.0 }
                Button { name: "Count", horizontal_alignment: HorizontalAlignment::Center, on_click: move |_| clicks.update(|c| *c += 1),
                    TextBlock { text: move || clicked_text(clicks.get()) }
                }
            }
        }
    }
    
    /// The text of the button after `clicks` clicks.
    fn clicked_text(clicks: i32) -> String {
        match clicks {
            1 => "Clicked 1 time".to_string(),
            _ => format!("Clicked {clicks} times"),
        }
    }
    
    fn main() {
        launch_themed(
            || ferroui_themes_winui::WinUITheme::new().as_style(),
            || window().title("Hello, World!").width(400.0).height(240.0).child(Hello()).into(),
            |_| {},
        );
    }
  5. Explore the repository

    Clone FerroUI to run the samples, the examples and the tests.

    Terminalsh

    git clone https://github.com/wieslawsoltes/FerroUI.git
    cd FerroUI
    
    # Hello, World! with builders, rsx! and hooks, and in XAML
    cargo run -p hello-world-builders
    cargo run -p hello-world-macros
    cargo run -p hello-world-hooks
    cargo run -p hello-world
    
    # The declarative API: a 7GUIs task, TodoMVC and the gallery
    cargo run -p seven-guis-counter-hooks
    cargo run -p todo-mvc
    cargo run -p view-gallery
    
    # The ControlCatalog sample application
    cargo run -p control-catalog-desktop
    
    # The gallery of the WinUI theme
    cargo run -p winui-theme-gallery --bin winui-theme-gallery
    
    # The tests of the workspace
    cargo test --workspace

App template

An application in a repository of its own

Solitaire, Ember, FerroDesign and Calculator are set up this way: FerroUI as a git submodule, its workspace dependencies and profiles copied into the application's workspace, and FerroUI's reusable workflow for CI and GitHub Pages. The guide is docs/apps.md. The cross-platform template generates this layout with desktop, browser, Android and iOS hosts.

Layouttext

MyApp/
  FerroUI/                     the submodule
  .cargo/config.toml           includes FerroUI/.cargo/config.toml
  .github/workflows/ci.yml     calls FerroUI's app.yml
  Cargo.toml                   the workspace, with the FerroUI blocks
  Cargo.lock                   committed (CI builds with --locked)
  src/... or MyApp/...         the crates of the application
  MyApp.Browser/               the browser host, with wwwroot/
  README.md, LICENSE, NOTICE.md

Terminalsh

git submodule add https://github.com/wieslawsoltes/FerroUI.git FerroUI

# Write the FerroUI blocks of Cargo.toml (CI runs it with --check)
python3 FerroUI/scripts/apps/sync-workspace.py

# Start from the lock file the framework is tested with
cp FerroUI/Cargo.lock Cargo.lock
cargo metadata --format-version 1 > /dev/null

# Publish the browser build with GitHub Pages
gh api -X POST repos/FerroUI/MyApp/pages -f build_type=workflow

.github/workflows/ci.ymlyaml

name: CI

on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
  app:
    uses: wieslawsoltes/FerroUI/.github/workflows/app.yml@main
    with:
      test: |
        -p my-app
      check: |
        -p my-app-desktop
      browser-package: my-app-browser

The workflow checks the conventions, builds and tests under an X server, builds and smoke-tests the browser site, optionally packages Android and iOS, and deploys the site to GitHub Pages from main.

Templates

Start a project with cargo generate

Project and item templates: rsx! with components and hooks, builders, XAML with MVVM or code-behind, a cross-platform repository with desktop, browser, Android and iOS hosts, a control library, and the items you add to a project. Each project template asks for its theme.

Terminalsh

cargo install cargo-generate

# Pick a template from the list, or name it
cargo generate --git https://github.com/FerroUI/templates
cargo generate --git https://github.com/FerroUI/templates rsx --name my-app
cd my-app
cargo run

The templates live in FerroUI/templates, one folder per template, and are made with cargo-generate. Each option is a prompt, or --define name=value on the command line.

The single-crate templates name every FerroUI crate at =. The cross-platform template uses the layout of an application repository: FerroUI as a git submodule and its reusable CI workflow.

rsx Project

A desktop application with the React-like API: rsx! trees, #[component] functions, a signal, and a component that renders again when its hook state changes (use_signal, #[component(rerender)]), as in samples/HelloWorld.Macros and samples/HelloWorld.Hooks.

  • src/main.rs
  • src/components.rs

Terminalsh

cargo generate --git https://github.com/FerroUI/templates rsx --name my-app
cd my-app
cargo run

Crates

The crates of a release

Every crate is released at the same version and depends on the others at exactly that version. Search by name or purpose, or narrow the list to a group.

Project status

Where FerroUI stands

FerroUI runs on macOS, Windows, Linux (X11, Wayland and the framebuffer), iOS, Android and in the browser. It was verified in continuous integration, in virtual machines, in the iOS simulator and on the Android emulator, not on a range of real devices.

API within 0.5

Within 0.5 the public API is kept; 0.6.0 may change it. The work towards the next version is published as previews, which may change any part of the public API.

Declarative UI: phases 0 to 6 built

Builders, rsx!, signals, components with hooks, the reconciler, XAML interoperation, tools, performance and scale, and futures, error boundaries and a router; what React has that it does not have yet is listed in declarative-ui-react.md.

Skia is the reference

Skia is the default and reference renderer, with HarfBuzz for text shaping.

Vello is experimental

The Vello backend has CPU, hybrid and GPU modes and is measured against Skia; its open work is in vello-backend.md.

Hot reload is experimental

A development engine with explicit adapters and release gates; parts of the build integration of XAML are open.

What works on each platform
PlatformWhat works
macOSWindows, input and input methods, clipboard, drag and drop, menus, tray icon, storage pickers, accessibility; Metal (default), OpenGL and software rendering
WindowsWindows, input methods and the input pane, clipboard and drag and drop, file dialogs, tray icon, UI Automation; software, ANGLE, WGL, DirectComposition, Windows.UI.Composition (with blur, acrylic and Mica) and a DXGI swap chain; Vulkan behind a feature
WinUI 3 hostingFerroUI content in a swap chain panel of a WinUI 3 window, with input, text input, cursors, drag and drop and automation
Linux, X11Input methods (XIM, IBus, Fcitx), clipboard, drag and drop, desktop portals, GTK file dialogs, menus and tray icon over D-Bus, accessibility over AT-SPI; software, GLX, EGL and Vulkan
Linux, WaylandOpt-in: toplevels with server-side or drawn decorations, popups, pointer, keyboard, touch and text input, clipboard, drag and drop, fractional scaling; shared memory, EGL or a dmabuf swap chain
Linux framebufferOne full-screen view on /dev/fb0 or a KMS output (OpenGL through EGL on GBM), with input through libinput or the event devices
iOSA view over Metal or OpenGL ES, touch, keyboard and text input, clipboard, storage, accessibility
AndroidA view over EGL, software or Vulkan, touch, keyboard and the input method, lifecycle, clipboard, storage, accessibility
BrowserA view in a web page rendered with WebGL 2 or a 2D canvas, input, clipboard, storage; an opt-in build renders from a worker thread
HeadlessWindows without a screen for tests, and a VNC server to see and drive an application remotely

Origins

Where FerroUI comes from

FerroUI started as a port of a .NET UI framework to Rust, and its object model, styling, layout, input and composition architecture follow that design; the XAML compiler front end comes from XamlX. Applications, themes and markup written against that model carry over with their structure. Other parts are native ports of their own sources: the WinUI 3 controls, theme and composition API, Xaml.Behaviors, the TreeDataGrid, LiveCharts2, Rx.NET, DynamicData, ReactiveUI and Splat.

The declarative Rust layer, compiled {x:Bind}, theme trimming, the Material 3 and macOS 26 themes, the portable media stack, 3D and the performance work are FerroUI's own.

What follows a source is tracked against it, member by member, in TRACKING.md, and every difference is recorded in DEVIATIONS.md. The projects and their licences are named in the Origins section of the README and in NOTICE.md.