Router Screen for Slint
KitScreen · Slint Kit 0.9.0
One screen of a router, shown while its route is current.
The still preview and demo follow the documentation theme. You can change it before or during the demo.

This preview runs the actual Slint components and their Rust code compiled to WebAssembly. Slint draws the interface in the browser; the downloadable project compiles the same example into a native application for your platform.
Try the component
Download the complete project, extract it and run cargo run --locked in its folder. To add this component to an application, follow Project setup, then copy the two files below.
The kit supplies the component's behavior and styles; Rust callbacks connect its typed values to your application.
Navigate between the list, detail and edit screens; inactive screens keep their local UI state. Use the controllers guide for a Rust-owned route stack.
ui/app.slint
import { KitThemeContext } from "@kit";
import { InterFont } from "@kit-fonts/inter.slint";
// SPDX-License-Identifier: GPL-3.0-or-later
import { KitRouter, KitScreen, KitButton, KitCard, RouteChange, KitTheme, KitThemes } from "@kit";
// In an application, Rust owns the stack with `Router<R>` and projects `route`, `change` and `can-go-back`.
export enum DemoRoute { projects, details, edit }
export component App inherits Window {
in-out property <string> status;
default-font-family: InterFont.family;
title: "KitScreen example";
preferred-width: 520px;
preferred-height: 310px;
max-width: 100000px;
max-height: 100000px;
background: root.theme.canvas;
in-out property <KitTheme> theme: KitThemeContext.current;
in-out property <DemoRoute> route: DemoRoute.projects;
in-out property <RouteChange> change: RouteChange.replace;
out property <bool> can-go-back: root.route != DemoRoute.projects;
KitRouter {
can-go-back: root.can-go-back;
back => { root.change = RouteChange.pop; root.route = root.route == DemoRoute.edit ? DemoRoute.details : DemoRoute.projects; }
KitScreen {
theme: root.theme; active: root.route == DemoRoute.projects; change: root.change;
VerticalLayout { padding: 24px; spacing: 16px; alignment: start;
Text { text: "Projects"; color: root.theme.text-primary; font-size: 20px * root.theme.text-scale; font-weight: 600; }
KitButton { theme: root.theme; text: "Open Atlas"; activated => { root.change = RouteChange.push; root.route = DemoRoute.details; } }
}
}
KitScreen {
theme: root.theme; active: root.route == DemoRoute.details; change: root.change;
VerticalLayout { padding: 24px; spacing: 16px; alignment: start;
Text { text: "Atlas"; color: root.theme.text-primary; font-size: 20px * root.theme.text-scale; font-weight: 600; }
Text { text: "Press Escape or Back to return to the list."; color: root.theme.text-secondary; wrap: word-wrap; }
KitButton { theme: root.theme; text: "Edit"; activated => { root.change = RouteChange.push; root.route = DemoRoute.edit; } }
}
}
KitScreen {
theme: root.theme; active: root.route == DemoRoute.edit; change: root.change;
VerticalLayout { padding: 24px; spacing: 16px; alignment: start;
Text { text: "Edit Atlas"; color: root.theme.text-primary; font-size: 20px * root.theme.text-scale; font-weight: 600; }
KitButton { theme: root.theme; text: "Back"; activated => { root.change = RouteChange.pop; root.route = DemoRoute.details; } }
}
}
}
}
src/main.rs
// SPDX-License-Identifier: GPL-3.0-or-later
slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> {
let app = App::new()?;
slint_kit::install(&app);
app.run()
}
Files: Cargo.toml · build.rs · ui/app.slint · src/main.rs
Bind active to the current route projected by Rust and change to the last navigation. Place the screen content as children.
A push slides the screen in from the trailing edge, a pop from the leading edge and a replace fades it, with the theme motion tokens; reduced motion removes the movement. An inactive screen is hidden once its exit ends: it takes no pointer, focus or accessibility. A screen that becomes active takes focus.
Visual composition
The file below describes the captured scene. For controller-driven components, it shows the displayed state without supplying the Rust wiring. Create a project.
Show the screenshot source

import { InterFont } from "@kit-fonts/inter.slint";
// SPDX-License-Identifier: GPL-3.0-or-later
import { KitRouter, KitScreen, KitButton, KitCard, RouteChange, KitTheme, KitThemes } from "@kit";
// In an application, Rust owns the stack with `Router<R>` and projects `route`, `change` and `can-go-back`.
export enum DemoRoute { projects, details, edit }
export component Example inherits Window {
in-out property <string> status;
default-font-family: InterFont.family;
title: "KitScreen example";
preferred-width: 520px;
preferred-height: 310px;
max-width: 100000px;
max-height: 100000px;
background: root.theme.canvas;
in-out property <KitTheme> theme: KitThemes.light;
in-out property <DemoRoute> route: DemoRoute.projects;
in-out property <RouteChange> change: RouteChange.replace;
out property <bool> can-go-back: root.route != DemoRoute.projects;
KitRouter {
can-go-back: root.can-go-back;
back => { root.change = RouteChange.pop; root.route = root.route == DemoRoute.edit ? DemoRoute.details : DemoRoute.projects; }
KitScreen {
theme: root.theme; active: root.route == DemoRoute.projects; change: root.change;
VerticalLayout { padding: 24px; spacing: 16px; alignment: start;
Text { text: "Projects"; color: root.theme.text-primary; font-size: 20px * root.theme.text-scale; font-weight: 600; }
KitButton { theme: root.theme; text: "Open Atlas"; activated => { root.change = RouteChange.push; root.route = DemoRoute.details; } }
}
}
KitScreen {
theme: root.theme; active: root.route == DemoRoute.details; change: root.change;
VerticalLayout { padding: 24px; spacing: 16px; alignment: start;
Text { text: "Atlas"; color: root.theme.text-primary; font-size: 20px * root.theme.text-scale; font-weight: 600; }
Text { text: "Press Escape or Back to return to the list."; color: root.theme.text-secondary; wrap: word-wrap; }
KitButton { theme: root.theme; text: "Edit"; activated => { root.change = RouteChange.push; root.route = DemoRoute.edit; } }
}
}
KitScreen {
theme: root.theme; active: root.route == DemoRoute.edit; change: root.change;
VerticalLayout { padding: 24px; spacing: 16px; alignment: start;
Text { text: "Edit Atlas"; color: root.theme.text-primary; font-size: 20px * root.theme.text-scale; font-weight: 600; }
KitButton { theme: root.theme; text: "Back"; activated => { root.change = RouteChange.pop; root.route = DemoRoute.details; } }
}
}
}
}
Public API
Inherits Rectangle.
Properties
The "Default" column repeats the initializer declared in the source; "—" is the zero value of the type, and a composite expression points to the source.
| Name | Type | Direction | Default |
|---|---|---|---|
theme |
KitTheme |
in |
KitThemeContext.current |
active |
bool |
in |
— |
change |
RouteChange |
in |
RouteChange.replace |
Types and variants
| Type | Declaration |
|---|---|
enum RouteChange |
push, pop, replace |
Functions
take-focus()