Dialog for Slint
KitDialog · Slint Kit 0.9.0
Centered modal dialog with a title, description, close button, scrollable body and footer actions.
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.
Edit the project name and choose an action. The example displays the action request; production business actions and closing remain host-owned.
ui/app.slint
import { KitThemeContext } from "@kit";
import { InterFont } from "@kit-fonts/inter.slint";
// SPDX-License-Identifier: GPL-3.0-or-later
import { ButtonIntent, DialogTabPolicy, KitDialog, KitTextField, KitTheme, KitThemes } from "@kit";
export component App inherits Window {
default-font-family: InterFont.family;
title: "KitDialog example";
preferred-width: 560px;
preferred-height: 420px;
max-width: 100000px;
max-height: 100000px;
background: root.theme.canvas;
in-out property <KitTheme> theme: KitThemeContext.current;
in-out property <string> status;
KitDialog { tab-policy: DialogTabPolicy.native; theme: root.theme; width: parent.width; height: parent.height; title: "Archive project"; description: "You can restore it later from the archive."; state: { open: true, topmost: true, busy: false }; actions: [{ token: 1, text: "Cancel", intent: ButtonIntent.secondary, disabled: false }, { token: 2, text: "Archive project", intent: ButtonIntent.primary, disabled: false }]; action-activated(token) => { root.status = "Action requested"; } KitTextField { theme: root.theme; label: "Project name"; text: "Field notes"; } if root.status != "": Text { text: root.status; color: root.theme.text-secondary; font-size: 12px * root.theme.text-scale; wrap: word-wrap; vertical-stretch: 0; } }
}
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
Mount it at the window root after scrolling content and give it the full viewport, like KitDrawer. Set title, description and size, place the body as children and pass the footer buttons in actions, each with a stable token. Handle action-activated(token), and connect the inherited dismiss and restore-focus to the modal stack and focus registry. Pass theme explicitly to application children. The standalone example uses tab-policy: DialogTabPolicy.native because it has no background controls. If the window has background controls, use host-managed traversal with focus-next, or keep native traversal and make those controls ineligible for focus while the dialog is open.
The panel is centered and its width follows size (small, medium, large), derived from the theme spacing unit and text scale and never wider than the window less a margin. Its height follows the content and stops at the window height less the same margin; past that the body scrolls under a fixed header and footer. An overflowing body joins the tab order and scrolls with the arrow, Page Up, Page Down, Space, Home and End keys. Opening focuses the close button, or the first action when show-close-button is false; the close button requests CloseReason.close-button. Actions are disabled while the dialog is busy or not topmost. Escape, system Back and backdrop presses follow KitDialogSurface.
Control accessibility
The panel is a group named by title and described by description; the close button is named by close-label. Slint 1.18 has no dialog role or modal state, so assistive technology still reaches inert content. Headless tests do not qualify VoiceOver, NVDA or physical IME.
Choose between built-in options and custom composition
Shared options
description— built-in property; custom composition example
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 { ButtonIntent, DialogTabPolicy, KitDialog, KitTextField, KitTheme, KitThemes } from "@kit";
export component Example inherits Window {
default-font-family: InterFont.family;
title: "KitDialog example";
preferred-width: 560px;
preferred-height: 420px;
max-width: 100000px;
max-height: 100000px;
background: root.theme.canvas;
in-out property <KitTheme> theme: KitThemes.light;
in-out property <string> status;
KitDialog { tab-policy: DialogTabPolicy.native; theme: root.theme; width: parent.width; height: parent.height; title: "Archive project"; description: "You can restore it later from the archive."; state: { open: true, topmost: true, busy: false }; actions: [{ token: 1, text: "Cancel", intent: ButtonIntent.secondary, disabled: false }, { token: 2, text: "Archive project", intent: ButtonIntent.primary, disabled: false }]; action-activated(token) => { root.status = "Action requested"; } KitTextField { theme: root.theme; label: "Project name"; text: "Field notes"; } if root.status != "": Text { text: root.status; color: root.theme.text-secondary; font-size: 12px * root.theme.text-scale; wrap: word-wrap; vertical-stretch: 0; } }
}
Public API
Inherits KitDialogSurface.
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 |
|---|---|---|---|
control-size |
ControlSize |
in |
ControlSize.medium |
title |
string |
in |
— |
description |
string |
in |
— |
close-label |
string |
in |
"Close dialog" |
show-close-button |
bool |
in |
true |
size |
DialogSize |
in |
DialogSize.medium |
actions |
[DialogAction] |
in |
— |
body-label |
string |
in |
— |
Available inherited properties
| Name | Type | Defined on | Default |
|---|---|---|---|
theme |
KitTheme |
KitDialogSurface |
KitThemeContext.current |
state |
DialogState |
KitDialogSurface |
— |
dismiss-on-backdrop |
bool |
KitDialogSurface |
true |
tab-policy |
DialogTabPolicy |
KitDialogSurface |
DialogTabPolicy.host |
modal-layer |
int |
KitDialogSurface |
0 |
Property details
Effect, default, states and constraints of the central properties, with a snippet that uses public mechanisms. Inherited properties carry the explanation of the component that declares them. The complete typed example and the Forms guide wire these properties end to end.
title
The dialog heading; it also names the panel for assistive technology.
KitDialog {
title: "Archive project";
}
description
Supporting text under the title; an empty string shows none.
- Default
- Empty.
KitDialog {
description: "You can restore it later.";
}
close-label
Accessible name of the close button; translate it for your locale.
- Default
"Close dialog".
KitDialog {
close-label: "Fermer";
}
show-close-button
Shows the header close button. When false, opening focuses the first action.
- Default
true.
KitDialog {
show-close-button: false;
}
size
Width preset of the panel: DialogSize.small, medium or large.
- Default
DialogSize.medium.
KitDialog {
size: DialogSize.large;
}
actions
Footer buttons in reading order; the last one is the primary action. Each DialogAction has a stable token, text, intent and disabled. An empty model shows no footer.
KitDialog {
actions: [{ token: 1, text: "Save", intent: ButtonIntent.primary, disabled: false }];
}
body-label
Accessible name of the body when it overflows and takes focus; the title when empty.
- Default
- Empty.
KitDialog {
body-label: "Project settings";
}
modal-layer
Makes this surface publish its layer in the window-level KitModalContext while it is open and topmost. Controls inside this dialog use the same layer, including its own buttons. Use distinct positive numbers for nested modals. 0 leaves the background to the host.
- Default
0(the host manages the background).
KitDialog {
modal-layer: 1;
}
Types and variants
| Type | Declaration |
|---|---|
enum ButtonIntent |
primary, secondary, outline, quiet, destructive, success, warning, information, link |
enum ControlSize |
compact, medium, comfortable |
struct DialogAction |
token: int, text: string, intent: ButtonIntent, disabled: bool |
enum DialogSize |
small, medium, large |
Callbacks
action-activated(int)— A footer action was activated. The argument is thetokenof itsDialogAction, never its position.restore-focus()— The dialog closed; restore focus to the exact opener.close-focus-observed(bool)— The close button gained or lost focus; forward it to the focus registry.