# Iced — Cross-Platform GUI Library for Rust > Iced is a cross-platform GUI library for Rust inspired by Elm. It provides a reactive programming model with type-safe messages and a compositor-based renderer for building native desktop applications. ## Install Save in your project root: # Iced — Cross-Platform GUI Library for Rust ## Quick Use ```bash # Add Iced to your Cargo project cargo init my_app && cd my_app cargo add iced # Replace src/main.rs with a counter example cat > src/main.rs << 'EOF2' use iced::widget::{button, column, text}; use iced::Element; #[derive(Default)] struct Counter { value: i64 } #[derive(Debug, Clone)] enum Message { Increment, Decrement } impl Counter { fn update(&mut self, msg: Message) { match msg { Message::Increment => self.value += 1, Message::Decrement => self.value -= 1, } } fn view(&self) -> Element { column![ button("+").on_press(Message::Increment), text(self.value), button("-").on_press(Message::Decrement), ].into() } } fn main() -> iced::Result { iced::run("Counter", Counter::update, Counter::view) } EOF2 cargo run ``` ## Introduction Iced brings the Elm Architecture to Rust desktop development. It separates state, messages, and view logic into distinct functions, making UIs predictable and testable. The library renders via wgpu (GPU-accelerated) or a software fallback, producing crisp native-feeling applications on Windows, macOS, and Linux. ## What Iced Does - Renders GPU-accelerated UIs using wgpu with a software fallback - Implements The Elm Architecture with typed messages and an update loop - Provides built-in widgets: buttons, text inputs, sliders, scrollable lists, and more - Supports async commands and subscriptions for background tasks - Enables custom widget creation with a flexible rendering API ## Architecture Overview An Iced application is a loop: the runtime calls `view()` to build a virtual widget tree, diffs it against the previous frame, and applies minimal updates to the rendered output. User interactions generate `Message` values routed to `update()`, which mutates state and optionally returns a `Command` for async work. The renderer backends (wgpu, tiny-skia) are swappable. ## Self-Hosting & Configuration - Add `iced` as a Cargo dependency; no system libraries required on most platforms - Enable feature flags for extras: `image`, `svg`, `canvas`, `tokio` - On Linux, ensure Vulkan drivers are installed for GPU rendering or use the software renderer - Customize themes via the `Theme` trait or use built-in light/dark themes - Cross-compile with standard Rust toolchain targets ## Key Features - Type-safe message passing catches UI logic errors at compile time - Responsive layout engine handles resizing without manual calculations - Built-in async runtime integrates with Tokio for network and file I/O - Canvas widget supports custom 2D drawing with paths, text, and images - Accessibility support is actively developed with screen reader integration ## Comparison with Similar Tools - **egui** — egui uses immediate mode (redraw every frame); Iced uses retained mode with diffing for efficiency - **Slint** — Slint has a declarative markup language; Iced is pure Rust code - **Tauri** — Tauri uses web views for UI; Iced renders natively via GPU - **GTK-rs** — GTK bindings wrap a C library; Iced is written entirely in Rust - **Druid** — Druid is in maintenance mode; Iced is actively developed with a growing community ## FAQ **Q: Does Iced support mobile platforms?** A: Experimental support exists, but Iced primarily targets desktop (Windows, macOS, Linux) today. **Q: How does performance compare to native toolkits?** A: GPU-accelerated rendering makes Iced competitive with native toolkits for most applications, including smooth animations. **Q: Can I use custom fonts and icons?** A: Yes. Load custom fonts via `Font::with_bytes()` and use SVG or image widgets for icons. **Q: Is Iced stable enough for production?** A: The API is still evolving between minor versions, but several production applications use Iced successfully. ## Sources - https://github.com/iced-rs/iced - https://iced.rs - https://book.iced.rs --- Source: https://tokrepo.com/en/workflows/asset-3a940055 Author: AI Open Source