Back to rankings

iced-rs/iced

Rusticed.rs

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

guigraphicsrustelminterfacewidgetwidgetstoolkituser-interfacerenderer-agnostic
Star Growth
Stars
31k
Forks
1.6k
Weekly Growth
Issues
357
10k20k30k
Jul 2019Nov 2021Mar 2024Jul 2026
Artifactscrates.iocargo add iced
README

Iced

Documentation Crates.io License Downloads Test Status Zulip Chat Discord Server

A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm.

Features

Iced is currently experimental software. Take a look at the roadmap and check out the issues.

Overview

Inspired by The Elm Architecture, Iced expects you to split user interfaces into four different concepts:

  • State — the state of your application
  • Messages — user interactions or meaningful events that you care about
  • View logic — a way to display your state as widgets that may produce messages on user interaction
  • Update logic — a way to react to messages and update your state

We can build something to see how this works! Let's say we want a simple counter that can be incremented and decremented using two buttons.

We start by modelling the state of our application:

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

Next, we need to define the possible user interactions of our counter: the button presses. These interactions are our messages:

#[derive(Debug, Clone, Copy)]
pub enum Message {
    Increment,
    Decrement,
}

Now, let's show the actual counter by putting it all together in our view logic:

use iced::widget::{button, column, text, Column};

impl Counter {
    pub fn view(&self) -> Column<'_, Message> {
        // We use a column: a simple vertical layout
        column![
            // The increment button. We tell it to produce an
            // `Increment` message when pressed
            button("+").on_press(Message::Increment),

            // We show the value of the counter here
            text(self.value).size(50),

            // The decrement button. We tell it to produce a
            // `Decrement` message when pressed
            button("-").on_press(Message::Decrement),
        ]
    }
}

Finally, we need to be able to react to any produced messages and change our state accordingly in our update logic:

impl Counter {
    // ...

    pub fn update(&mut self, message: Message) {
        match message {
            Message::Increment => {
                self.value += 1;
            }
            Message::Decrement => {
                self.value -= 1;
            }
        }
    }
}

And that's everything! We just wrote a whole user interface. Let's run it:

fn main() -> iced::Result {
    iced::run(Counter::update, Counter::view)
}

Iced will automatically:

  1. Take the result of our view logic and layout its widgets.
  2. Process events from our system and produce messages for our update logic.
  3. Draw the resulting user interface.

Read the book, the documentation, and the examples to learn more!

Implementation details

Iced was originally born as an attempt at bringing the simplicity of Elm and The Elm Architecture into Coffee, a 2D game library I am working on.

The core of the library was implemented during May 2019 in this pull request. The first alpha version was eventually released as a renderer-agnostic GUI library. The library did not provide a renderer and implemented the current tour example on top of ggez, a game library.

Since then, the focus has shifted towards providing a batteries-included, end-user-oriented GUI library, while keeping the ecosystem modular.

Contributing / Feedback

If you want to contribute, please read our contributing guidelines for more details.

Feedback is also welcome! You can create a new topic in our Zulip forum or come chat to our Discord server.

Sponsors

The development of Iced is sponsored by the Cryptowatch team at Kraken.com

Related repositories
ocornut/imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

C++MIT Licenseguigamedev
74.9k11.9k
dbeaver/dbeaver

Free universal database tool and SQL client

JavaMavenApache License 2.0sqldatabase
dbeaver.io
51.1k4.3k
NaiboWang/EasySpider

A visual no-code/code-free web crawler/spider易采集:一个可视化浏览器自动化测试/数据采集/网页爬虫软件,可以无代码图形化的设计和执行爬虫任务。别名:ServiceWrapper面向Web应用的智能化服务封装系统。

JavaScriptnpmGNU Affero General Public License v3.0code-freecrawler
easyspider.net
44.3k5.4k
HeyPuter/puter

🌐 The Internet Computer! Free, Open-Source, and Self-Hostable.

TypeScriptnpmGNU Affero General Public License v3.0desktopdesktop-environment
puter.com
42.8k4k
appsmithorg/appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.

TypeScriptnpmApache License 2.0low-codeadmin-dashboard
appsmith.com
40.4k4.7k
GyulyVGC/sniffnet

Comfortably monitor your Internet traffic 🕵️‍♂️

Rustcrates.ioApache License 2.0network-analysisnetworking
sniffnet.app
40.1k1.8k
yewstack/yew

Rust / Wasm framework for creating reliable and efficient web applications

Rustcrates.ioApache License 2.0rustweb
yew.rs
32.7k1.5k
tqdm/tqdm

:zap: A Fast, Extensible Progress Bar for Python and CLI

PythonPyPIOtherprogressbarprogressmeter
tqdm.github.io
31.2k1.5k
AvaloniaUI/Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The future of .NET UI

C#MIT Licensec-sharpxaml
avaloniaui.net
31.2k2.8k
flameshot-org/flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:

C++GNU General Public License v3.0screenshotqt
flameshot.org
30.4k2k
emilk/egui

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

Rustcrates.ioApache License 2.0guirust
egui.rs
29.8k2.1k
reflex-dev/reflex

🕸️ Web apps in pure Python 🐍

PythonPyPIApache License 2.0pythonframework
reflex.dev
28.7k1.7k