Masonry
A foundational framework for Rust GUI libraries
Masonry is a foundational framework for building GUI libraries in Rust.
The developers of Masonry are developing Xilem, a reactive UI library built on top of Masonry. Masonry's API is geared towards creating GUI libraries; if you are creating an application, we recommend also considering Xilem.
Masonry gives you a platform-independent manager, which owns and maintains a widget tree. It also gives you tools to inspect that widget tree at runtime, write unit tests on it, and generally have an easier time debugging and maintaining your app.
The framework is not opinionated about what your user-facing abstraction will be: you can implement immediate-mode GUI, the Elm architecture, functional reactive GUI, etc., on top of Masonry.
It is opinionated about its internals: things like text focus, pointer interactions and accessibility events are often handled in a centralized way.
Masonry is built on top of:
- Vello and wgpu for 2D graphics.
- Parley for the text stack.
- AccessKit for plugging into accessibility APIs.
Masonry can be used with any windowing library which allows the window content to be rendered using wgpu.
There are currently two backends for using Masonry to create operating system windows:
- masonry_winit for most platforms.
masonry_android_viewfor Android. This can currently be found in the Android View repository, and is not yet generally usable.
Example
The to-do-list example looks like this, using masonry_winit as the backend:
use ;
use LogicalSize;
use AlphaColor;
use Padding;
use Length;
use default_property_set;
use ;
use ;
use Window;
const TEXT_INPUT_TAG: = new;
const LIST_TAG: = new;
const WIDGET_SPACING: Length = const_px;
/// Return initial to-do-list without items.
Running this will open a window that looks like this:

Feature flags
The following crate feature flags are available:
tracy: Enables creating output for the Tracy profiler usingtracing-tracy. This can be used by installing Tracy and connecting to a Masonry with this feature enabled.testing: Re-exports the test harness from [masonry_testing].
Debugging features
Masonry apps currently ship with several debugging features built in:
- A rudimentary widget inspector - toggled by the F11 key.
- A debug mode painting widget layout rectangles - toggled by the F12 key.
- Optional automatic registration of a tracing subscriber, which outputs to the console and to a file in the dev profile.
If you want to use your own subscriber, simply set it before starting masonry - in this case masonry will not set a subscriber.
Minimum supported Rust Version (MSRV)
This version of Masonry has been verified to compile with Rust 1.88 and later.
Future versions of Masonry might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases.
Community
Discussion of Masonry development happens in the Linebender Zulip, specifically the #masonry channel. All public content can be read without logging in.
Contributions are welcome by pull request. The Rust code of conduct applies.
License
Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)