Expand description

Slint interpreter library

With this crate, you can load a .slint file at runtime and show its UI.

You only need to use this crate if you do not want to use pre-compiled .slint code, which is the normal way to use Slint, using the slint crate

The entry point for this crate is the ComponentCompiler type, which you can use to create ComponentDefinition with the ComponentCompiler::build_from_source or ComponentCompiler::build_from_path functions.

Note about async functions

Compiling a component is async but in practice, this is only asynchronous if ComponentCompiler::set_file_loader is set and its future is actually asynchronous. If that is not used, then it is fine to use a very simple executor, such as the one provided by the spin_on crate


This example loads a .slint dynamically from a path and show errors if any:

use slint_interpreter::{ComponentDefinition, ComponentCompiler, ComponentHandle};

let mut compiler = ComponentCompiler::default();
let definition =
if let Some(definition) = definition {
    let instance = definition.create();

This example load a .slint from a string and set some properties:

use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};

let code = r#"
    MyWin := Window {
        property <string> my_name;
        Text {
            text: "Hello, " + my_name;

let mut compiler = ComponentCompiler::default();
let definition =
    spin_on::spin_on(compiler.build_from_source(code.into(), Default::default()));
let instance = definition.unwrap().create();
instance.set_property("my_name", Value::from(SharedString::from("World"))).unwrap();

Feature flags

  • compat-0-2-0 (enabled by default) — Mandatory feature: This feature is required to keep the compatibility with Slint 0.2.0 Newer patch version may put current functionality behind a new feature that would be enabled by default only if this feature was added

  • display-diagnostics — enable the print_diagnostics function to show diagnostic in the console output

  • std (enabled by default) — Enable use of the Rust standard library.


  • backend-qt (enabled by default) — The Qt backend feature uses Qt for the windowing system integration and rendering. This backend is required to use the native style. It requires Qt 5.15 or later to be installed. If Qt is not installed, the backend will not be operational

  • backend-gl-all (enabled by default) — The GL backend uses the winit crate for the windowing system integration, and the femtovg crate for the rendering. With this feature, all windowing systems are supported. For a smaller build, omit this feature and select one of the other specific backend-gl-XX features.

  • backend-gl-x11 — Simliar to backend-gl-all this enables the GL backend but only with support for the X Window System on Unix.

  • backend-gl-wayland — Simliar to backend-gl-all this enables the GL backend but only with support for the Wayland window system on Unix.


Migration from previous versions

This module contains a few function use by tests


(Re-export from corelib.) Color represents a color in the Slint run-time, represented using 8-bit channels for red, green, blue and the alpha (opacity). It can be conveniently converted using the to_ and from_ (a)rgb helper functions:

ComponentCompiler is the entry point to the Slint interpreter that can be used to load .slint files or compile them on-the-fly from a string.

ComponentDefinition is a representation of a compiled component from .slint markup.

This represent an instance of a dynamic component

This structure represent a diagnostic emitted while compiling .slint code.

(Re-export from corelib.) A string type used by the Slint run-time.

(Re-export from corelib.) SharedVector holds a reference-counted read-only copy of [T].

This type represents a runtime instance of structure in .slint.

Struct that’s used to hold weak references of a Slint component

This type represents a window towards the windowing system, that’s used to render the scene of a component. It provides API to control windowing system specific aspects such as the position on the screen.


(Re-export from corelib.) A brush is a data structure that is used to describe how a shape, such as a rectangle, path or even text, shall be filled. A brush can also be applied to the outline of a shape, that means the fill of the outline itself.

This enum describes whether a Window is allowed to be hidden when the user tries to close the window. It is the return type of the callback provided to Window::on_close_requested.

This enum describes the level or severity of a diagnostic message produced by the compiler.

This enum describes a low-level access to specific graphics APIs used by the renderer.

This enum describes the different rendering states, that will be provided to the parameter of the callback for set_rendering_notifier on the slint::Window.

This enum describes the different error scenarios that may occur when the applicaton registers a rendering notifier on a crate::Window.

This is a dynamically typed value used in the Slint interpreter. It can hold a value of different types, and you should use the From or TryInto traits to access the value.

This enum represents the different public variants of the Value enum, without the contained values.


This trait describes the common public API of a strongly referenced Slint component. It allows creating strongly-referenced clones, a conversion into/ a weak pointer as well as other convenience functions.

This trait is used to obtain references to global singletons exported in .slint markup. Alternatively, you can use ComponentHandle::global to obtain access.

Internal trait that’s used to map rendering state callbacks to either a Rust-API provided impl FnMut or a struct that invokes a C callback and implements Drop to release the closure on the C++ side.


Adds the specified function to an internal queue, notifies the event loop to wake up. Once woken up, any queued up functors will be invoked.

Print the diagnostics to stderr

Enters the main event loop. This is necessary in order to receive events from the windowing system in order to render to the screen and react to user input.