A theme supplies the control templates and resources that make controls visible and usable. FerroUI has themes for five design languages, each covering every control with light and dark variants: WinUI 3 (ferroui-themes-winui), Fluent (ferroui-themes-fluent), Material 3 Expressive (ferroui-themes-material), macOS 26 (ferroui-themes-macos), and Simple (ferroui-themes-simple). Install a theme before expecting a templated control to have its final appearance: a declarative application chooses it in launch_themed (launch uses Fluent), and an application class adds it to its styles, for example this.styles().add(FluentTheme::new().as_style()).
The styling system is the same for declarative Rust and XAML: selectors, styles, control themes, resources, and transitions. The examples below are XAML; styles, themes & motion writes the same styles in Rust with style("Button.primary").set(..).
Style a class of controls
Section titled “Style a class of controls”<StackPanel xmlns="https://github.com/ferroui" Spacing="12"> <StackPanel.Styles> <Style Selector="Button.primary"> <Setter Property="FontSize" Value="16" /> <Setter Property="Padding" Value="16,8" /> </Style> </StackPanel.Styles> <Button Classes="primary" Content="Continue" /></StackPanel>Selectors decide which controls receive setters. Use classes to represent application intent; avoid styling by a transient visual-tree position unless the template contract requires it. In rsx!, the same class is class: "primary" and the style is added with styles: [style("Button.primary").set(..)].
Check that the selector matches
Section titled “Check that the selector matches”Run the style example inside an application with a theme installed. The button’s padding and font size should change. Remove Classes="primary": it should return to its theme’s defaults. Add a second unclassified button to verify that the style affects only the intended controls.
Keep styles at the narrowest useful scope. A view’s Styles can define a local primary action; application-wide styles should describe shared product conventions. Button lists the properties you can set, while Style defines the public style contract.
Property value sources
Section titled “Property value sources”A style setter is one value source among several. A local value or animation may take precedence. When a setter appears ineffective, inspect the property’s resolved value and source. Repeatedly adding more specific selectors cannot override every value source.
Themes and templates
Section titled “Themes and templates”A control theme packages the styling and template for a control. A template defines the visuals a control creates; replacing it can remove necessary named parts, focus indicators, or visual states. Begin with the current theme’s implementation when creating a substantial replacement.
Light and dark
Section titled “Light and dark”Use theme resources instead of literal foreground/background pairs for ordinary controls. Test changing the requested theme variant at runtime. A component reads the variant with use_theme_variant() and a theme resource with use_resource_as, and a ThemeVariantScope element switches the variant of a part of the tree. A custom brush that looks acceptable on a light background may erase text or focus feedback in dark mode.
For platform materials such as Mica or native blur, consult the platform guide. A browser-rendered preview is not proof of native material behavior.
Choose the smallest appearance change
Section titled “Choose the smallest appearance change”| Desired change | Start with |
|---|---|
| More space around a button label | A Padding setter |
| A shared accent color | A resource used by the relevant setters |
| A complete control visual structure | A control theme/template with required parts preserved |
| A new interaction model | A custom control with explicit behavior |
Public APIs and next steps
Section titled “Public APIs and next steps”Style,Setter, andThemeVariant— styles and variants.FluentTheme— Fluent theme setup.styleanduse_theme_variant— styles and variants from declarative Rust.- Resources, custom controls, and accessibility.
Check dynamically loaded controls in a trimmed app
Section titled “Check dynamically loaded controls in a trimmed app”Built-in themes can include only the control styles the application needs. Test every dynamically loaded view in the release configuration you intend to ship. If a type fails to load, confirm its XAML namespace and markup registration. If it loads but has no visual template, check that the application includes its theme and roots that control’s theme resources.
For library-owned templates, declare the item type for bindings and use resource keys for reusable brushes and converters. See compiled binding setup and the theme authoring guide in the FerroUI repository.