Actively developed · Breaking changes are still expected.

Slint Kit Documentation

Search the documentation

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

    Navigation

    Tab panel for Slint

    KitTabPanel · Slint Kit 0.9.0

    Composed panel associated with stable selection, retaining its native content.

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

    Composed panel associated with stable selection, retaining its native 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.

    Use Left/Right and Enter/Space to switch the selected panel, then Tab to its named content. References stay stable when tabs move.

    ui/app.slint

    // SPDX-License-Identifier: GPL-3.0-or-later
    import { KitTabs, KitTabPanel, KitStack, KitFieldDescription, LayoutSpace, OptionRow, SelectionRef, KitTheme, KitThemes } from "@kit";
    import { InterFont } from "@kit-fonts/inter.slint";
    export component App inherits Window {
        preferred-width: 620px; preferred-height: 360px;
        max-width: 100000px; max-height: 100000px;
        default-font-family: InterFont.family;
        in-out property <KitTheme> theme: KitThemes.light;
        background: root.theme.canvas;
        private property <SelectionRef> overview: {present: true, token: 11};
        private property <SelectionRef> settings: {present: true, token: 37};
        in-out property <SelectionRef> selected: root.overview;
        KitStack {
            theme: root.theme; inset: LayoutSpace.roomy;
            tabs := KitTabs {
                theme: root.theme; selected <=> root.selected;
                typeahead-enabled: false;
                options: [
                    {token: root.overview.token, generation: 1, label: "Overview"},
                    {token: root.settings.token, generation: 1, label: "Settings"},
                ];
            }
            KitStack { theme: root.theme; gap: LayoutSpace.none;
                KitTabPanel {
                    theme: root.theme; state: tabs.state; tab: root.overview;
                    accessible-name: "Overview"; tab-stop: true; inset: LayoutSpace.compact;
                    KitFieldDescription { theme: root.theme; text: "The panel stays associated with its key when the tab order changes."; }
                }
                KitTabPanel {
                    theme: root.theme; state: tabs.state; tab: root.settings;
                    accessible-name: "Settings"; tab-stop: true; inset: LayoutSpace.compact;
                    KitFieldDescription { theme: root.theme; text: "Editors can remain mounted: selection changes only the visible panel."; }
                }
            }
        }
    }
    
    

    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 state to tabs.state and tab to Choices::selection(&key), using the same source. Never identify a panel by a visible index. Group panels in KitStack with gap: LayoutSpace.none so collapsed items reserve no inter-panel spacing.

    The active panel follows the available accepted selection, independently of the merely focused tab. Absent, uninitialized or unavailable selections collapse to zero and hide content. Children stay mounted with their native text/history. Selection changes never refocus automatically. The panel composes KitStack and forwards theme/gap/inset; give supplied children their theme explicitly. Editable/read-only/disabled access remains owned by each child.

    Control accessibility

    Exposes tab-panel with accessible-name. Leave tab-stop false to reach native child controls directly; enable it for static content. take-focus() focuses its scope only while active. The scope uses the theme focus indicator. Slint 1.18.1 provides no tab-to-panel identifier relation; role and name 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
    Composed panel associated with stable selection, retaining its native content.
    Browser capture of the same Slint example, femtovg renderer.
    // SPDX-License-Identifier: GPL-3.0-or-later
    import { KitTabs, KitTabPanel, KitStack, KitFieldDescription, LayoutSpace, OptionRow, SelectionRef, KitTheme, KitThemes } from "@kit";
    import { InterFont } from "@kit-fonts/inter.slint";
    export component Example inherits Window {
        preferred-width: 620px; preferred-height: 360px;
        max-width: 100000px; max-height: 100000px;
        default-font-family: InterFont.family;
        in-out property <KitTheme> theme: KitThemes.light;
        background: root.theme.canvas;
        private property <SelectionRef> overview: {present: true, token: 11};
        private property <SelectionRef> settings: {present: true, token: 37};
        in-out property <SelectionRef> selected: root.overview;
        KitStack {
            theme: root.theme; inset: LayoutSpace.roomy;
            tabs := KitTabs {
                theme: root.theme; selected <=> root.selected;
                typeahead-enabled: false;
                options: [
                    {token: root.overview.token, generation: 1, label: "Overview"},
                    {token: root.settings.token, generation: 1, label: "Settings"},
                ];
            }
            KitStack { theme: root.theme; gap: LayoutSpace.none;
                KitTabPanel {
                    theme: root.theme; state: tabs.state; tab: root.overview;
                    accessible-name: "Overview"; tab-stop: true; inset: LayoutSpace.compact;
                    KitFieldDescription { theme: root.theme; text: "The panel stays associated with its key when the tab order changes."; }
                }
                KitTabPanel {
                    theme: root.theme; state: tabs.state; tab: root.settings;
                    accessible-name: "Settings"; tab-stop: true; inset: LayoutSpace.compact;
                    KitFieldDescription { theme: root.theme; text: "Editors can remain mounted: selection changes only the visible panel."; }
                }
            }
        }
    }
    
    

    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
    theme KitTheme in KitThemeContext.current
    gap LayoutSpace in LayoutSpace.regular
    inset LayoutSpace in LayoutSpace.none
    state SelectState in —
    tab SelectionRef in —
    accessible-name string in —
    tab-stop bool in false
    active 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.

    gap LayoutSpace · in

    Spacing forwarded to the composed KitStack.

    Default
    LayoutSpace.regular

    inset LayoutSpace · in

    Padding forwarded to the composed KitStack.

    Default
    LayoutSpace.none

    state SelectState · in

    Current SelectState projection from the tab strip.

    tab SelectionRef · in

    Stable SelectionRef projected from this panel’s domain key.

    tab-stop bool · in

    Add a scope stop for static content; child controls keep native traversal.

    Default
    false

    active bool · out

    Read-only computed output matching the available accepted selection.

    Types and variants

    Type Declaration
    enum LayoutSpace none, tight, compact, regular, roomy, section
    enum SelectionAvailability absent, available, unavailable
    struct SelectionRef present: bool, token: int
    struct SelectState selection-availability: SelectionAvailability, selected: SelectionRef, active: SelectionRef, open: bool, active-index: int, generation: int

    Functions

    See also