waft-winui 0.7.0

WinUI 3 controls and Fluent styling for the Waft UI framework
Documentation

Waft WinUI

WinUI controls and Fluent styling for Waft.

The library ports control templates, theme resources and behavior from Microsoft’s WinUI. Waft handles rendering, layout and input.

Try it

Waft requires nightly Rust:

rustup install nightly
cargo run -p winui_gallery

Run the gallery from the Waft repository, where the kit lives.

Use it

[dependencies]
waft-winui = "0.5.0"

Build the app with FluentApp, the kit's MaterialApp: it shows the light or dark theme and the accent, gives text WinUI's body style, selection the accent and scrollables WinUI's thin bar and clamped edge, installs the Fluent icon font, and gives each page WinUI's Frame entrance. Controls that show popups need an Overlay ancestor. An app's content goes in a Page, whose background reaches under a phone's system bars while its content stays clear of them and of the keyboard.

FluentApp::new()
    .theme(FluentTheme::light())
    .dark_theme(FluentTheme::dark())
    .home(Page::new().content(Button::text("Save", Listener::new(|_| {}))))
    .into_widget()

A WidgetsApp still works without a FluentApp; call install_icon_font yourself then, and give its page_route_builder FluentPageRoute::new for the same entrance. FluentPageRoute is a page route like MaterialPageRoute, so it can be pushed on its own.

A ThemeScope can also change WinUI's theme resources for its subtree, as XAML's resource dictionaries do: any in both themes, then light or dark. Each resource is a field named after its XAML key.

ThemeScope::new(Theme::Light, app)
    .any(|r| r.control_corner_radius = [6.0; 4])
    .dark(|r| r.text_fill_color_primary = Color::from_argb(255, 240, 240, 240))

ThemeScope::overriding(child) changes the enclosing scope's resources for one control, as <Control.Resources> does.

The gallery demonstrates application setup, font registration and control state.

Contributing

Porting guidance, tests and resource generation: the porting-winui skill.

License

MIT. Microsoft’s source and the bundled icon font retain their third-party notices.