31,981
stars
+81+84+310
1,727
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions
README
Iced
![Documentation][documentation]
A cross-platform GUI library for Rust focused on simplicity and type-safety.
Inspired by [Elm].
Features
Simple, easy-to-use, batteries-included API
Type-safe, reactive programming model
[Cross-platform support] (Windows, macOS, Linux, and the Web)
Responsive layout
Built-in widgets (including [text inputs], [scrollables], and more!)
Custom widget support (create your own!)
[Debug tooling with performance metrics and time traveling]
First-class support for async actions (use futures!)
Modular ecosystem split into reusable parts:
A [renderer-agnostic native runtime] enabling integration with existing systems
Two built-in renderers leveraging [wgpu] and [tiny-skia]
[iced_wgpu] supporting Vulkan, Metal and DX12
[iced_tiny_skia] offering a software alternative as a fallback
A [windowing shell]
__Iced is currently experimental software.__ [Take a look at the roadmap] and
[check out the issues].
[Cross-platform support]: https://raw.githubusercontent.com/iced-rs/iced/master/docs/images/todos_desktop.jpg
[text inputs]: https://iced.rs/examples/text_input.mp4
[scrollables]: https://iced.rs/examples/scrollable.mp4
[Debug tooling with performance metrics and time traveling]: https://github.com/user-attachments/assets/2e49695c-0261-4b43-ac2e-8d7da5454c4b
[renderer-agnostic native runtime]: runtime/
[wgpu]: https://github.com/gfx-rs/wgpu
[tiny-skia]: https://github.com/RazrFalcon/tiny-skia
[iced_wgpu]: wgpu/
[iced_tiny_skia]: tiny_skia/
[windowing shell]: winit/
[Take a look at the roadmap]: ROADMAP.md
[check out the issues]: https://github.com/iced-rs/iced/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:
rust
[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__:
rust
[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__:
rust
use iced::widget::{button, column, text, Widget};
impl Counter {
pub fn view(&self) - impl Widget {
// 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::In