Actively developed · Breaking changes are still expected.

Slint Kit Documentation

Search the documentation

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

    Navigation

    Popover for Slint

    KitPopover · Slint Kit 0.9.0

    Trigger button that opens an anchored panel holding any content.

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

    Trigger button that opens an anchored panel holding any content.
    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.

    Open Project details and dismiss the popover with Escape or by clicking outside. The status records opening and dismissal.

    ui/app.slint

    import { KitThemeContext } from "@kit";
    import { InterFont } from "@kit-fonts/inter.slint";
    // SPDX-License-Identifier: GPL-3.0-or-later
    import { KitPopover, KitTheme, KitThemes } from "@kit";
    
    export component App inherits Window {
        default-font-family: InterFont.family;
        title: "KitPopover example";
        preferred-width: 480px;
        preferred-height: 320px;
        max-width: 100000px;
        max-height: 100000px;
        background: root.theme.canvas;
        in-out property <KitTheme> theme: KitThemeContext.current;
        in-out property <string> status: "No action yet";
        VerticalLayout {
            padding: 24px;
            spacing: 12px;
            alignment: start;
            KitPopover {
                theme: root.theme;
                text: "Project details";
                popup-width: 280px * root.theme.text-scale;
                opened => { root.status = "Details opened"; }
                dismissed(reason) => { root.status = "Details closed"; }
                Text { text: "Field notes"; color: root.theme.text-primary; font-size: 14px * root.theme.text-scale; wrap: word-wrap; vertical-stretch: 0; max-height: self.preferred-height; }
                Text { text: "Updated this morning"; color: root.theme.text-secondary; font-size: 12px * root.theme.text-scale; wrap: word-wrap; vertical-stretch: 0; max-height: self.preferred-height; }
            }
            Text { text: root.status; color: root.theme.text-secondary; font-size: 12px * root.theme.text-scale; }
        }
    }
    
    

    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

    Set text for the trigger and place the panel content as children. Handle opened() and dismissed(CloseReason); call show() or dismiss(reason) to drive the panel from code.

    The panel sits below the trigger, or above it when there is more room, shifts horizontally and shrinks in height to stay inside the window, using the same placement as the field popups. An outside press, which includes a press on the trigger itself, or Escape closes it; Down Arrow on the trigger opens it. dismissed reports escape, programmatic (for dismiss), trigger-toggle (the trigger activated by keyboard or assistive action while open) or host-closed (an outside press, including one on the trigger, or any other native closure). Escape and dismiss return focus to the trigger; an outside press does not move focus itself. The panel takes focus when presented so that Escape works; Tab moves through its controls. popup-height (default 320px) caps the panel height. Slint forbids reading or calling an element of a popup from outside it, so react to panel content through its own callbacks.

    Control accessibility

    The trigger is a button with expanded state reflecting open. The panel is a plain container: give interactive content its own accessible names. Headless tests do not qualify VoiceOver, NVDA or physical IME.

    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
    Trigger button that opens an anchored panel holding any content.
    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 { KitPopover, KitTheme, KitThemes } from "@kit";
    
    export component Example inherits Window {
        default-font-family: InterFont.family;
        title: "KitPopover example";
        preferred-width: 480px;
        preferred-height: 320px;
        max-width: 100000px;
        max-height: 100000px;
        background: root.theme.canvas;
        in-out property <KitTheme> theme: KitThemes.light;
        in-out property <string> status: "No action yet";
        VerticalLayout {
            padding: 24px;
            spacing: 12px;
            alignment: start;
            KitPopover {
                theme: root.theme;
                text: "Project details";
                popup-width: 280px * root.theme.text-scale;
                opened => { root.status = "Details opened"; }
                dismissed(reason) => { root.status = "Details closed"; }
                Text { text: "Field notes"; color: root.theme.text-primary; font-size: 14px * root.theme.text-scale; wrap: word-wrap; vertical-stretch: 0; max-height: self.preferred-height; }
                Text { text: "Updated this morning"; color: root.theme.text-secondary; font-size: 12px * root.theme.text-scale; wrap: word-wrap; vertical-stretch: 0; max-height: self.preferred-height; }
            }
            Text { text: root.status; color: root.theme.text-secondary; font-size: 12px * root.theme.text-scale; }
        }
    }
    
    

    Download this example

    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
    modal-layer int in —
    theme KitTheme in KitThemeContext.current
    control-size ControlSize in ControlSize.medium
    intent ButtonIntent in ButtonIntent.secondary
    text string in —
    leading-icon IconGlyph in —
    trailing-icon IconGlyph in —
    accessible-name string in —
    disabled bool in —
    popup-width length in max(root.width, KitMetrics.select-popup-min-width(root.theme))
    popup-height length in 320px
    open bool out —
    has-focus bool out —

    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.

    modal-layer int · in

    The modal layer this component belongs to; 0 is the window. While a KitDialogSurface or KitDrawer with a positive modal-layer is open and topmost, the trigger is inert and show() does nothing. Give a component placed inside a modal that modal's layer number.

    Default
    0 (window).
    KitPopover {
        modal-layer: 1;
    }

    popup-width length · in

    Width of the panel, capped at the window width minus a gap on each side.

    Default
    The larger of the trigger width and the select popup minimum width.
    popup-width: 320px;

    popup-height length · in

    Largest height of the panel; a taller content is clipped.

    Default
    320px.
    popup-height: 240px;

    open bool · out

    True while the panel is presented. It turns false when the panel closes for any reason, including a native outside press.

    out property <bool> expanded: control.open;

    has-focus bool · out

    True while the trigger button owns focus.

    out property <bool> trigger-focused: control.has-focus;

    Types and variants

    Type Declaration
    enum ButtonIntent primary, secondary, outline, quiet, destructive, success, warning, information, link
    enum CloseReason escape, outside-press, system-back, trigger-toggle, close-button, programmatic, host-closed
    enum ControlSize compact, medium, comfortable

    Callbacks

    Functions

    See also