#gui #gtk #gtk4 #elm


An idiomatic GUI library inspired by Elm and based on gtk4-rs

27 releases

0.6.0-alpha.2 Mar 13, 2023
0.5.1 Mar 14, 2023
0.5.0-rc.1 Dec 21, 2022
0.5.0-beta.5 Nov 26, 2022
0.4.0-beta.2 Nov 26, 2021

#10 in GUI

Download history 186/week @ 2022-11-30 237/week @ 2022-12-07 183/week @ 2022-12-14 410/week @ 2022-12-21 216/week @ 2022-12-28 232/week @ 2023-01-04 294/week @ 2023-01-11 286/week @ 2023-01-18 334/week @ 2023-01-25 646/week @ 2023-02-01 679/week @ 2023-02-08 951/week @ 2023-02-15 971/week @ 2023-02-22 1022/week @ 2023-03-01 879/week @ 2023-03-08 792/week @ 2023-03-15

3,794 downloads per month
Used in 17 crates (10 directly)

Apache-2.0 OR MIT

6.5K SLoC


CI Matrix Relm4 on crates.io Relm4 docs Relm4 book Minimum Rust version 1.64 dependency status

An idiomatic GUI library inspired by Elm and based on gtk4-rs. Relm4 is a new version of relm that's built from scratch and is compatible with GTK4 and libadwaita.

Why Relm4

We believe that GUI development should be easy, productive and delightful.
The gtk4-rs crate already provides everything you need to write modern, beautiful and cross-platform applications. Built on top of this foundation, Relm4 makes developing more idiomatic, simpler and faster and enables you to become productive in just a few hours.

Our goals

  • ⏱️ Productivity
  • Simplicity
  • 📎 Outstanding documentation
  • 🔧 Maintainability



Relm4 depends on GTK4: How to install GTK4.


  • relm4-macros several macros for declarative UI definitions.
  • relm4-components is a collections of reusable components you can easily integrate into your application.
  • relm4-template is a starter template for creating Relm4 applications in the Flatpak package format.

To use all features, just add this to your Cargo.toml:

relm4 = "0.6.0-alpha.2"
relm4-components = "0.6.0-alpha.2"


The relm4 crate has four feature flags:

Flag Purpose
macros Enable macros by re-exporting relm4-macros
libadwaita Improved support for libadwaita
libpanel Improved support for libpanel
dox Linking to the underlying C libraries is skipped to allow building the docs without the dependencies
gnome_43 Enable all version feature flags of all dependencies to match the GNOME 43 SDK
gnome_42 Enable all version feature flags of all dependencies to match the GNOME 42 SDK

The macros feature is a default feature.


Several example applications are available at examples/.

📸 Screenshots from the example apps

A simple counter app

Simple app screenshot light Simple app screenshot dark

use gtk::prelude::*;
use relm4::prelude::*;

struct App {
    counter: u8,

enum Msg {

impl SimpleComponent for App {
    type Init = u8;
    type Input = Msg;
    type Output = ();

    view! {
        gtk::Window {
            set_title: Some("Simple app"),
            set_default_size: (300, 100),

            gtk::Box {
                set_orientation: gtk::Orientation::Vertical,
                set_spacing: 5,
                set_margin_all: 5,

                gtk::Button {
                    set_label: "Increment",
                    connect_clicked => Msg::Increment,

                gtk::Button {
                    set_label: "Decrement",
                    connect_clicked => Msg::Decrement,

                gtk::Label {
                    set_label: &format!("Counter: {}", model.counter),
                    set_margin_all: 5,

    // Initialize the component.
    fn init(
        counter: Self::Init,
        root: &Self::Root,
        sender: ComponentSender<Self>,
    ) -> ComponentParts<Self> {
        let model = App { counter };

        // Insert the code generation of the view! macro here
        let widgets = view_output!();

        ComponentParts { model, widgets }

    fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
        match msg {
            Msg::Increment => {
                self.counter = self.counter.wrapping_add(1);
            Msg::Decrement => {
                self.counter = self.counter.wrapping_sub(1);

fn main() {
    let app = RelmApp::new("relm4.example.simple");

Projects using Relm4


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Feedback and contributions are highly appreciated!


~518K SLoC