Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Coming from egui, Iced or Slint

Updated 2026-11-26 · Ferrokit 0.15 · Markdown

If you’ve built a GUI in Rust before, most of Ferrokit will feel familiar. Two things are different, and the rest follows from them:

  • The views are AppKit’s. A button is an NSButton and a table is an NSTableView. Ferrokit doesn’t draw widgets, and nothing renders a frame on the GPU. That’s why it’s Mac only, and why VoiceOver, text input, Dark Mode and the system’s tables work without extra code.
  • Views are built once, then updated in place. egui runs your UI code every frame and Iced calls view after every message. Ferrokit runs your view code once, when the window opens. The parts that change are closures over signals, and when a signal changes, only the views that read it update.

The same ideas, side by side

eguiIcedSlintFerrokit
Statefields of your app struct, read each framethe state struct update changespropertys in the .slint fileSignal<T>: a Copy handle, read with get(), changed with set/update
Eventsif ui.button(..).clicked()a Message enum, matched in updatecallbacks (clicked => { .. })closures: button("Add", move || ..)
Describing the UIcode that runs every frameview(&self) -> Element, rebuilt after each message.slint markupfunctions returning impl View, run once
What changes on screeneverything, every framethe diff of the new viewbound propertieseach view reading a changed signal, and nothing else
Layoutui.horizontal, ui.verticalrow!, column!HorizontalLayout, VerticalLayouthstack, vstack, grid, spacer, .padding(..), .frame(..)
Listsa for loopcolumn(items.iter().map(..))for item in itemsfor_each(items, row), keyed by Identifiable
Tablesegui_extras::TableBuildertable (0.14)StandardTableViewtable(&model): an NSTableView, a million rows
Background workyour own threadsTask::performspawn_local, threadsspawn, background(..).await in spawn_local, Resource::new
Windowseframe::run_nativeiced::applicationone component per windowApp::new(..).window(Window::new(..)), open(..)
LookVisualsthemesstyles and propertiesthe system’s, plus .font(..), .color(..), .background(..), .corner_radius(..)
Testsegui_kittesticed_testthe testing backendself-checks that drive the real controls (ferrokit::testing)

One app, four ways

A counter: a label and a button. In egui, the UI is code that runs every frame, and the button’s result is a bool you test:

struct Counter { count: i32 }

impl eframe::App for Counter {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.label(format!("Clicked {} times", self.count));
            if ui.button("Click me").clicked() {
                self.count += 1;
            }
        });
    }
}

In Iced, a click sends a message, update changes the state, and view builds the whole tree again:

#[derive(Default)]
struct Counter { count: i32 }

#[derive(Debug, Clone)]
enum Message { Clicked }

impl Counter {
    fn update(&mut self, message: Message) {
        match message {
            Message::Clicked => self.count += 1,
        }
    }

    fn view(&self) -> Element<'_, Message> {
        column![
            text(format!("Clicked {} times", self.count)),
            button("Click me").on_press(Message::Clicked),
        ]
        .padding(20)
        .into()
    }
}

In Slint, the UI is markup with properties, and Rust code drives it from outside:

export component Counter inherits Window {
    in-out property <int> count: 0;
    VerticalLayout {
        Text { text: "Clicked \{count} times"; }
        Button { text: "Click me"; clicked => { count += 1; } }
    }
}

In Ferrokit, the state is a signal. The label is given a closure, so it follows the signal, and the button is given the action to run:

use ferrokit::*;

fn main() {
    let count = Signal::new(0);
    App::new("Counter")
        .window(Window::new("Counter").size(320.0, 140.0).view(
            vstack((
                text(move || format!("Clicked {} times", count.get())),
                button("Click me", move || count.update(|n| *n += 1)),
            ))
            .padding(20.0),
        ))
        .run();
}

There’s no Message enum and no update function. A click runs its closure, the closure changes count, and the one NSTextField that reads count gets new text. The stack, the button and the window are never touched again.

A bigger example: a to-do list

Here’s a list you can add to and clear items from, with a count. Where Iced would have Message::DraftChanged, Message::Add and Message::Remove(id), here each control gets a signal or a closure:

use ferrokit::*;

#[derive(Clone)]
struct Todo {
    id: u32,
    title: String,
}

impl Identifiable for Todo {
    type Id = u32;
    fn id(&self) -> u32 {
        self.id
    }
}

fn main() {
    let todos = Signal::new(Vec::<Todo>::new());
    let draft = Signal::new(String::new());
    let next_id = Signal::new(1);
    // A closure that captures only signals is `Copy`: use it twice.
    let add = move || {
        let title = draft.get_untracked().trim().to_string();
        if title.is_empty() {
            return;
        }
        let id = next_id.get_untracked();
        next_id.set(id + 1);
        todos.update(|v| v.push(Todo { id, title }));
        draft.set(String::new());
    };
    let list = for_each(move || todos.get(), move |todo: Todo| {
        let id = todo.id;
        hstack((
            text(todo.title),
            spacer(),
            button("Done", move || todos.update(|v| v.retain(|t| t.id != id))),
        ))
    });
    App::new("Todos")
        .window(Window::new("Todos").size(360.0, 400.0).view(
            vstack((
                hstack((
                    text_field(&draft).placeholder("New to-do").on_submit(add),
                    button("Add", add).disabled(move || draft.with(|d| d.trim().is_empty())),
                )),
                scroll(vstack((list,))),
                text(move || format!("{} left", todos.with(Vec::len))),
            ))
            .padding(16.0),
        ))
        .run();
}

What to notice, coming from the other toolkits:

  • text_field(&draft) is bound both ways. Typing changes draft, and draft.set(..) changes the field. There’s no on_input message to handle.
  • for_each keeps rows by identity. Adding a to-do builds one row, and removing one drops one. The others, their NSViews included, stay as they are, so a row’s focus or scroll position isn’t lost.
  • get() tracks and get_untracked() doesn’t. Inside a view’s closure (text(move || ..), .disabled(move || ..)), get() subscribes the view to the signal. In an action you just want the value, so use get_untracked().
  • button("Add", add).disabled(..) takes a closure, so the button enables and disables itself as draft changes.

Habits to unlearn

  • A value isn’t a binding. text(format!("{}", count.get())) reads the count once, when the window opens, and never changes. Give text a closure: text(move || format!("{}", count.get())). The same goes for every modifier that takes impl IntoValue: a plain value is fixed, and a closure follows its signals.
  • Don’t rebuild views to change them. In Iced the whole tree is rebuilt after each message; here, building a new view means a new AppKit view. That’s slow, and it loses focus and selection. Put the changing part in a closure, or in dynamic(..) when a whole subtree has to change.
  • No per-frame loop. Nothing runs unless a signal changes or an event arrives. For a clock or a live feed, on_frame calls you once per display frame, and a background thread can spawn its results back.
  • Main thread only. AppKit is single-threaded, and so are signals and views. Heavy work goes to spawn or background(..), which hand the result back to the main thread.
  • Most styling is already done. Controls look and behave as macOS draws them, in light and Dark Mode, at every text size. Reach for .font, .color, .background and .corner_radius when you want your own look, not to make a button look like a button.

Where to go next