Actively developed · Breaking changes are still expected.

Slint Kit Documentation

Search the documentation

    ↑ ↓ to browse · Enter to open · Escape to close

    Dialogs

    Alert dialog for Slint

    KitAlertDialog · Slint Kit 0.9.0

    Confirmation dialog with a question, a cancel button and a confirm button.

    The still preview and demo follow the documentation theme. You can change it before or during the demo.

    Confirmation dialog with a question, a cancel button and a confirm button.
    Slint components with their built-in Tailwind appearance, rendered in the browser.

    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.

    Choose Keep project or Delete project. This example only displays the requested action and never deletes application data.

    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, KitAlertDialog, KitTheme, KitThemes } from "@kit";
    
    export component App inherits Window {
        default-font-family: InterFont.family;
        title: "KitAlertDialog example";
        preferred-width: 560px;
        preferred-height: 360px;
        max-width: 100000px;
        max-height: 100000px;
        background: root.theme.canvas;
        in-out property <KitTheme> theme: KitThemeContext.current;
        in-out property <string> status;
        KitAlertDialog { tab-policy: DialogTabPolicy.native; theme: root.theme; width: parent.width; height: parent.height; title: "Delete this project?"; description: "The project and its notes are removed for everyone."; confirm-text: "Delete project"; cancel-text: "Keep project"; confirm-intent: ButtonIntent.destructive; state: { open: true, topmost: true, busy: false }; confirmed => { root.status = "Deletion requested"; } cancelled => { root.status = "Deletion cancelled"; } 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 like KitDialog. Set title, description, confirm-text and cancel-text, and handle confirmed() and cancelled(). Also handle the inherited dismiss for Escape and system Back. Use confirm-intent: ButtonIntent.destructive when confirming deletes something. 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.

    It has no close button and ignores backdrop presses, so the user answers explicitly. Opening focuses Cancel, so a stray Return never confirms. Escape and system Back report dismiss with CloseReason.escape or .system-back; the Cancel button reports cancelled(). The panel uses the small size unless you set size. Children appear between the description and the buttons.

    Control accessibility

    The panel is a group named by title and described by description. Slint 1.18 has no alert dialog role, so assistive technology does not announce it as an alert. Headless tests do not qualify VoiceOver, NVDA or physical IME.

    Choose between built-in options and custom composition

    Shared options

    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
    Confirmation dialog with a question, a cancel button and a confirm button.
    Browser capture of the same Slint example, femtovg renderer.
    import { InterFont } from "@kit-fonts/inter.slint";
    // SPDX-License-Identifier: GPL-3.0-or-later
    import { ButtonIntent, DialogTabPolicy, KitAlertDialog, KitTheme, KitThemes } from "@kit";
    
    export component Example inherits Window {
        default-font-family: InterFont.family;
        title: "KitAlertDialog example";
        preferred-width: 560px;
        preferred-height: 360px;
        max-width: 100000px;
        max-height: 100000px;
        background: root.theme.canvas;
        in-out property <KitTheme> theme: KitThemes.light;
        in-out property <string> status;
        KitAlertDialog { tab-policy: DialogTabPolicy.native; theme: root.theme; width: parent.width; height: parent.height; title: "Delete this project?"; description: "The project and its notes are removed for everyone."; confirm-text: "Delete project"; cancel-text: "Keep project"; confirm-intent: ButtonIntent.destructive; state: { open: true, topmost: true, busy: false }; confirmed => { root.status = "Deletion requested"; } cancelled => { root.status = "Deletion cancelled"; } 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; } }
    }
    
    

    Download this example

    Public API

    Inherits KitDialog.

    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
    confirm-text string in "Confirm"
    cancel-text string in "Cancel"
    confirm-intent ButtonIntent in ButtonIntent.primary
    confirm-disabled bool 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
    control-size ControlSize KitDialog ControlSize.medium
    title string KitDialog —
    description string KitDialog —
    close-label string KitDialog "Close dialog"
    show-close-button bool KitDialog true
    size DialogSize KitDialog DialogSize.medium
    actions [DialogAction] KitDialog —
    body-label string KitDialog —

    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.

    confirm-text string · in

    Label of the confirm button.

    Default
    "Confirm".
    KitAlertDialog {
        confirm-text: "Delete project";
    }

    cancel-text string · in

    Label of the cancel button.

    Default
    "Cancel".
    KitAlertDialog {
        cancel-text: "Keep project";
    }

    confirm-intent ButtonIntent · in

    Visual intent of the confirm button; use destructive for irreversible actions.

    Default
    ButtonIntent.primary.
    KitAlertDialog {
        confirm-intent: ButtonIntent.destructive;
    }

    confirm-disabled bool · in

    Disables the confirm button, for example until the user acknowledges a warning.

    Default
    false.
    KitAlertDialog {
        confirm-disabled: true;
    }

    modal-layer int · in · defined on KitDialogSurface

    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;
    }

    title string · in · defined on KitDialog

    The dialog heading; it also names the panel for assistive technology.

    KitDialog {
        title: "Archive project";
    }

    description string · in · defined on KitDialog

    Supporting text under the title; an empty string shows none.

    Default
    Empty.
    KitDialog {
        description: "You can restore it later.";
    }

    close-label string · in · defined on KitDialog

    Accessible name of the close button; translate it for your locale.

    Default
    "Close dialog".
    KitDialog {
        close-label: "Fermer";
    }

    show-close-button bool · in · defined on KitDialog

    Shows the header close button. When false, opening focuses the first action.

    Default
    true.
    KitDialog {
        show-close-button: false;
    }

    size DialogSize · in · defined on KitDialog

    Width preset of the panel: DialogSize.small, medium or large.

    Default
    DialogSize.medium.
    KitDialog {
        size: DialogSize.large;
    }

    actions [DialogAction] · in · defined on KitDialog

    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 string · in · defined on KitDialog

    Accessible name of the body when it overflows and takes focus; the title when empty.

    Default
    Empty.
    KitDialog {
        body-label: "Project settings";
    }

    Types and variants

    Type Declaration
    enum ButtonIntent primary, secondary, outline, quiet, destructive, success, warning, information, link

    Callbacks

    See also