Description
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.
Relm4 alternatives and similar packages
Based on the "GUI" category.
Alternatively, view Relm4 alternatives based on common mentions on social networks and blogs.
-
SixtyFPS
DISCONTINUED. Slint is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript. [Moved to: https://github.com/slint-ui/slint] -
Kiss-ui
A simple UI framework for Rust built on top of IUP (http://webserver2.tecgraf.puc-rio.br/iup/)
WorkOS - The modern identity platform for B2B SaaS
Do you think we are missing an alternative of Relm4 or a related project?
Popular Comparisons
README
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
Documentation
- ๐ The Relm4 book
- ๐ Rust documentation
Dependencies
Relm4 depends on GTK4: How to install GTK4.
Ecosystem
Relm4 has two crates that extend the core functionality:
- relm4-macros provides a
widget
macro that simplifies UI creation - relm4-components is a collections of reusable components you can easily integrate into your application
To use all features, just add this to your Cargo.toml
:
relm4 = { version = "0.4", features = ["macros"] }
relm4-components = "0.4"
Features
The relm4
crate has four feature flags:
Flag | Purpose |
---|---|
macros | Enable macros by re-exporting relm4-macros |
tokio-rt | Adds the AsyncRelmWorker type that uses an asynchronous update function |
libadwaita | Improved support for libadwaita |
all | Enable all features |
Examples
Several example applications are available at [relm4-examples/](relm4-examples/).
[๐ธ Screenshots from the example apps](assets/screenshots)
A simple counter app
[Simple app screenshot light](assets/screenshots/simple-light.png) [Simple app screenshot dark](assets/screenshots/simple-dark.png)
use gtk::prelude::{BoxExt, ButtonExt, GtkWindowExt, OrientableExt};
use relm4::{send, AppUpdate, Model, RelmApp, Sender, WidgetPlus, Widgets};
#[derive(Default)]
struct AppModel {
counter: u8,
}
enum AppMsg {
Increment,
Decrement,
}
impl Model for AppModel {
type Msg = AppMsg;
type Widgets = AppWidgets;
type Components = ();
}
impl AppUpdate for AppModel {
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::Increment => {
self.counter = self.counter.wrapping_add(1);
}
AppMsg::Decrement => {
self.counter = self.counter.wrapping_sub(1);
}
}
true
}
}
#[relm4::widget]
impl Widgets<AppModel, ()> for AppWidgets {
view! {
gtk::ApplicationWindow {
set_title: Some("Simple app"),
set_default_width: 300,
set_default_height: 100,
set_child = Some(>k::Box) {
set_orientation: gtk::Orientation::Vertical,
set_margin_all: 5,
set_spacing: 5,
append = >k::Button {
set_label: "Increment",
connect_clicked(sender) => move |_| {
send!(sender, AppMsg::Increment);
},
},
append = >k::Button {
set_label: "Decrement",
connect_clicked(sender) => move |_| {
send!(sender, AppMsg::Decrement);
},
},
append = >k::Label {
set_margin_all: 5,
set_label: watch! { &format!("Counter: {}", model.counter) },
}
},
}
}
}
fn main() {
let model = AppModel::default();
let app = RelmApp::new(model);
app.run();
}
License
Licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
Contribution
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!
*Note that all licence references and agreements mentioned in the Relm4 README section above
are relevant to that project's source code only.