Editor’s note: This article was updated on 3 January 2024 to add Yew and Xilem to the list of Rust GUI libraries.
Graphical user interfaces (GUIs) provide an intuitive visual frontend for interacting with computers. GUIs use visual indicators like icons, windows, and menus for better user interaction and experience, unlike command-line interfaces (CLIs) that use text for input and output operations.
Rust has been growing in popularity over time, likely due to its flexibility and vibrant open source community. Developers use Rust for things like systems design, web development, and building GUIs. Many packages and crates are available for developing fast, complex GUI applications in Rust.
This article will review a few popular Rust GUI libraries and frameworks, including Tauri, Druid, Xilem, Slint, gtk-rs, fltk-rs, iced, relm, Azul, egui, and Yew. We’ll compare these libraries, discussing when they’re a good choice for building your GUI application. Let’s get started!
Tauri is an open source package that enables developers to create lightweight, web-based desktop applications using Rust.
Tauri leverages JavaScript, WebAssembly, and other web technologies to create a seamless development experience. The package provides a simple API for creating and customizing desktop applications, making it easy for developers to build cross-platform applications that run on Windows, Mac, and Linux.
One critical feature of the Tauri package is its cross-platform compatibility. With Tauri, you can create a single GUI that can run on multiple platforms with minimal modification, resulting in a “build for one, run on all” scenario.
Thanks to its web-based architecture, Tauri applications are lightweight and fast. Tauri runs on web technologies, and apps run smoothly on low-end hardware.
Finally, Tauri uses an event-driven architecture that allows for easy interaction with events. Tauri provides access to native APIs and JavaScript interoperability that enables the packages to access JavaScript functions from Rust code.
Adding Tauri to your project is simple; you just need to add the package to the dependencies
section of the Cargo.toml
file in your project’s root directory:
[dependencies] tauri = "0.9.0"
Once you’ve added Tauri as a project dependency, you can import it into your Rust file by adding the following code to the top of your file:
use tauri::{Builder, Tauri};
N.B., Druid’s maintainers have indicated that it is being discontinued in favor of other projects based on the same general principles, such as Xilem (an experimental Rust native UI framework that you can read more about in the next section).
Druid is a powerful and flexible Rust library for building GUIs for desktop applications. One of the critical features of Druid is its layout system, which allows for an easy and intuitive widget layout based on constraints, making it easy to create visually consistent and responsive user interfaces.
Druid also provides a wide range of built-in widgets, including buttons, labels, and text inputs that you can use to customize the look and feel of your application.
Druid is cross-platform compatible, with support for Windows, macOS, and Linux, allowing you to write your application once and run it on multiple platforms without any modifications. Druid also provides a comprehensive event-handling system that makes it easy to respond to user interactions and update user interfaces in real time.
To get started with the Druid package, add the following code to the dependencies
in your cargo.toml
file:
[dependencies] druid = "0.7.0"
To import Druid into a Rust file, use the following code:
use druid::{AppLauncher, WindowDesc};
Xilem is an experimental Rust UI library inspired by popular UI libraries including SwiftUI, Flutter, and Elm. Xilem’s development principle revolves around performance and organization.
Xilem is lightweight and efficient because it emphasizes minimal updates. It uses a centralized state control with a state manager that simplifies data handling while offering predictable updates.
If you’re a Swift developer familiar with SwiftUI, you should find Xilem easy to use because its syntax and concepts resemble SwiftUI’s.
At the moment, there are no releases for the library; however, it is in active development. The project has 2.3k GitHub stars, which is impressive for a new project.
Slint is an open source, Rust-based UI framework for building native user interfaces. Slint provides a comprehensive yet simple solution for building applications for embedded devices, microcontrollers, and desktops.
One of Slint’s key features is its support for multiple programming languages. Developers can combine Slint-based GUIs with backend logic written in either Rust, C++, or JavaScript. It also comes with a wide variety of prebuilt UI components, like buttons, forms, modals, and more, so developers don’t have to spend time building them from scratch. The prebuilt components are also customizable, so you can adapt them to the specific needs of your application.
In addition to being responsive across different screen sizes, Slint is cross-platform across different operating systems and processor architectures. Finally, Slint includes a robust set of APIs for building custom components.
To install the Slint package, add the following code to the dependencies
section of your cargo.toml
file:
[dependencies] slint = "1.0.2"
There are various ways to include Slint files in Rust. The most straightforward way is to inline the .slint
code using the slint!
macro:
fn main() { MainWindow::new().unwrap().run().unwrap(); } slint::slint! { export component MainWindow inherits Window { Text { text: "hello world"; color: green; } } }
Overall, Slint is a powerful and versatile solution for building native applications in Rust. Its prebuilt components, responsive design, and custom component APIs make it a valuable tool for any Rust developer working on desktops and embedded projects.
GTK is a popular, cross-platform, object-oriented widget toolkit developed by The GNOME Project. It is used for building portable GUI applications that work on Unix, Windows, and macOS systems in several languages, from Python to JavaScript, C, and Rust.
There are various versions of the GTK project, each with its own changes and upgrades.
The gtk-rs project provides safe Rust bindings for GNOME stack-based libraries, like the GTK 3 and GTK 4 libraries. The gtk3-rs
and gtk4-rs
libraries provide GTK 3 and GTK 4 functionalities, respectively.
To start using the gtk-rs libraries, you’ll need the Rust toolchain and the GTK library. After creating a project, add the library to your dependencies in the Cargo.toml
file for the GTK 4 crate:
gtk = { version = "X.X", package = "gtk4" }
If you’re on macOS or Linux, install the GTK 4 library using the brew package manager:
brew install gtk4
Check these pages for installation instructions on the various Linux Distros and Windows. After installing GTK 4 and adding it to your dependencies, you can import the crate as follows:
use gtk::prelude::*; use gtk::Application;
The gtk-rs book is a good resource for learning how to build GUIs in Rust using the library.
Within the developer community, the GTK library is very popular; many popular Linux GUI applications use the GTK library and GNOME stack. The gtk-rs library is just one of the many Rust GUI libraries ready for production.
FLTK (Fast Light Toolkit) is a lightweight, cross-platform-supported toolkit for building GUIs. FLTK is supported on Windows, macOS, and UNIX systems and was originally built for C++. If you use the FLTK toolkit to create a GUI application, the application will look the same on all supported operating systems.
The fltk-rs library provides Rust bindings for the FLTK toolkit. The fltk-rs crate supports old architecture with more than 80 customizable widgets and more than four supported theme schemes, including the GTK scheme. You can also use the fltk-theme crate for more customizations.
The fltk-rs library is quick to install, build, start, and run with a single execution. To get started with the fltk-rs crate, all you have to do is add the project as a dependency to your Cargo.toml
file and install the library on your computer.
If you’re on a macOS or Linux computer, you can install the fltk-rs library using the following brew command:
brew install fltk
For other operating systems, you can find instructions for installing the fltk library in the docs. Next, add the project as a dependency to your Cargo.toml
file:
[dependencies] fltk = { version = "^1.3", features = ["fltk-bundled"] }
After adding the project and installing the library, you can import the crate into your project as follows:
use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};
Check out the fltk-rs documentation for a detailed overview of its functionalities and uses. The fltk library is quite popular, with more than 1.4k stars on GitHub at the time of writing. It is growing fast, with more than 200 releases, and you can use the library in production without concerns.
Inspired by the Elm Architecture, iced-rs is a renderer-agnostic, batteries included, data-centered cross-platform Rust library for building GUIs and frontends. iced provides an easy-to-use, reactive programming model with first-class support for async actions and custom widgets.
GUI applications built with the iced library can run on Windows, macOS, Linux, and the web (using the DOM) with a responsive layout. iced splits applications into four concepts:
You can easily get started using the iced library for frontend web applications. The process is similar to building GUI applications, and you can check out the iced documentation to learn more about the package.
Due to its versatility, the iced library is one of the most popular Rust libraries. However, despite being used in many projects, iced is somewhat unstable and is undergoing rapid development. But the master branch is constantly changing and might be expensive to use in production, so you might want to consider using older releases.
You can find projects for inspiration, code examples, and library implementations in the iced repository.
Initially written in Rust, relm is a GTK-based, asynchronous GUI library. It’s inspired by the Elm Architecture to simplify GTK library usage and provide an Elm-like experience.
Like the GTK library, you can build cross-platform GUIs using relm. You’ll need to have experience using the GTK library to use relm and get the most out of the library.
To use relm, you need to add the GTK and relm libraries to your project’s dependencies in your Cargo.toml
file. You’ll also need to have the gtk library installed:
[dependencies] gtk = "0.9.0" relm = "0.20.0" relm-derive = "0.20.0"
Finally, import the gtk crate alongside the relm crates:
use relm::{connect, Relm, Update, Widget}; use gtk::prelude::*; use gtk::{Window, Inhibit,a WindowType}; use relm_derive::Msg;
The Rust community appreciates relm for the Elm-like experience that other Rust libraries, like Yew, Seed, and iced, provide.
At the time of writing, relm is in its beta stage, meaning it hasn’t been appropriately tested and is changing rapidly. With that said, you may not want to use it in production just yet.
The Azul framework is a reactive GUI framework for building desktop GUIs in Rust, C, and C++. Powered by WebRender, Azul is a document object model, similar to HTML and CSS. Because Azul leverages WebRender, it provides features like gradients, box shadows, border styling, and CSS transforms.
The Azul framework also provides many inbuilt widgets, more than 60 frames per second animation, cross-platform native dialogues, SVG parsing, dynamic linking through the shared library, and HTML to Rust compilation for hot reloads.
To get started with the Azul framework, add it to your project’s dependencies:
[dependencies] azul = "1.0.0-alpha"
Then, import the crates to your project and use them:
use azul::prelude::*; use azul::widgets::{button::Button, label::Label};
The Azul framework is well-documented to help you get started building GUIs.
Azul takes a different approach to GUI development, and, so far, the framework has been used in more than 200 Rust projects. The framework is functional, and according to the documentation, you can use it in production.
egui is an immediate-mode, easy-to-use, portable library for building GUIs in Rust that run on the web, computers, and game engines in development. egui aims to be the easiest library for building web applications in Rust.
egui provides a safe, responsive, friendly, and portable experience for building GUIs with no callbacks and minimal dependencies. The project has WASM, WGPU, Winit, and Glow official integrations, and there are many other third-party integrations for using egui with other tools and engines.
egui’s native backend uses glow
, which works nicely with Windows and macOS. If you’re on Linux, execute this command to set up the required backends:
sudo apt-get install -y libclang-dev libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
Then, execute the following command to add egui as a dependency:
cargo add egui
Here’s how you can import egui for use in your projects:
use eframe::egui;
The egui library is in active development, and there are 16 releases and over 18k GitHub stars at the time of writing.
Yew.rs is a Rust WebAssembly framework for building web applications. It is a component-based framework that simplifies the process of creating interactive UIs. Yew features a macro for declaring interactive HTML with Rust expressions, and you can render the UI on a server for added benefits.
You’ll find Yew easy to use if you have experience with frameworks like React, Elm, and JSX. While Yew is mostly used for building web application UIs, its WebAssembly support allows you to build GUIs that run on WebAssembly-enabled devices.
To get started with Yew, add the WASM target to your Rust project development environment:
rustup target add wasm32-unknown-unknown
Next, add Yew to your project as a dependency:
[dependencies] # this is the development version of Yew yew = { git = "https://github.com/yewstack/yew/", features = ["csr"] }
Now you can go ahead and start tinkering with the framework. Visit the Yew documentation to learn more about Yew and how you can use it to advance your projects.
Yew is a household name in the Rust ecosystem; however, it doesn’t have any stable versions rolled out, so you should brace yourself for major refactoring due to breaking API changes during development. It has garnered over 10.7k users over its 35 releases with nearly 30k stars.
The GUI libraries discussed in this article each offer different features and functionalities. The comparison table below will help you to make choices and considerations for your next project:
Popularity (by GitHub stars) | Project users | Compatibility | Production ready | |
---|---|---|---|---|
gtk-rs | 1.5k | 1.4k | Windows, Linux, macOS | No |
fltk-rs | 1.4k | 1k | Windows, Linux, macOS | Yes |
iced | 21.6k | 2.9k | Windows, macOS, Linux, and Web | No |
relm | 2.4k | not-in-view | Windows, Linux, macOS | No |
Azul | 5.7k | not-in-view | Windows, Linux, macOS | Yes (alpha release) |
egui | 18k | 11.3k | Windows, macOS, Linux, and Web | No |
Tauri | 72.8k | 554 | macOS, Windows, Linux, Android and iOS | Yes |
Slint | 12k | 544 | macOS, Windows, Linux, Android and iOS, Web | Yes |
Druid | 9.2k | 2.1k | macOS, Windows, Linux/BSD and Web | No |
Yew | 29.3k | 10.7k | Web/WebAssembly | No |
Xilem | 2.3k | – | Linux | No releases yet |
Many of the GUI libraries in the Rust ecosystem are premature projects (compared to those in other ecosystems) with many good features. Be sure to consider the state of the library for your project; it’s risky to use untested libraries.
You’ll also want to consider the library’s compatibility based on what you’re building and where the project will run. It’s always recommended to thoroughly test and evaluate any library or tool before using it in a production environment.
There are many other GUI libraries in the Rust ecosystem; you can find a comprehensive list on Are We GUI Yet and LibHunt. In this tutorial, we explored several popular GUI libraries in the Rust ecosystem, including Druid, Xilem, Slint, Tauri, gtk-rs, fltk-rs, iced, relm, Azul, egui, and Yew. Hopefully, this tutorial has given you some insight into choosing the best GUI library for your next project!
Debugging Rust applications can be difficult, especially when users experience issues that are hard to reproduce. If you’re interested in monitoring and tracking the performance of your Rust apps, automatically surfacing errors, and tracking slow network requests and load time, try LogRocket.
LogRocket is like a DVR for web and mobile apps, recording literally everything that happens on your Rust application. Instead of guessing why problems happen, you can aggregate and report on what state your application was in when an issue occurred. LogRocket also monitors your app’s performance, reporting metrics like client CPU load, client memory usage, and more.
Modernize how you debug your Rust apps — start monitoring for free.
Hey there, want to help make our blog better?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up nowEfficient initializing is crucial to smooth-running websites. One way to optimize that process is through lazy initialization in Rust 1.80.
Design React Native UIs that look great on any device by using adaptive layouts, responsive scaling, and platform-specific tools.
Angular’s two-way data binding has evolved with signals, offering improved performance, simpler syntax, and better type inference.
Fix sticky positioning issues in CSS, from missing offsets to overflow conflicts in flex, grid, and container height constraints.
5 Replies to "The state of Rust GUI libraries"
If you utilise Bevy, you can have egui render on the web.
the best for production is not listed: Tauri
How can druid not be listed?
No mention of Slint (formerly SixtyFPS).
Druid is discounted btw as per the project status
https://github.com/linebender/druid?tab=readme-ov-file#project-status