Actively developed · Breaking changes are still expected.

Slint Kit Documentation

Search the documentation

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

    Choices and values

    Chip Button for Slint

    KitChipButton · Slint Kit 0.9.0

    Pressable chip for a status, filter or shortcut, with an optional icon and a tone.

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

    Pressable chip for a status, filter or shortcut, with an optional icon and a tone.
    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 In transit, Delayed or another chip. Rust accepts the typed filter, updates the selected chip and shows the matching status below. Tab and Space activate the focused chip.

    ui/app.slint

    
    // SPDX-License-Identifier: GPL-3.0-or-later
    import { InterFont } from "@kit-fonts/inter.slint";
    import { LucideIcons } from "@kit-icons/all.slint";
    import { KitChipButton, KitTheme, KitThemeContext, KitMetrics, Tone, TypographyRole } from "@kit";
    // A closed set the code owns: Rust receives the generated OrderFilter enum.
    export enum OrderFilter { all, awaiting-shipment, in-transit, delayed, returned }
    export component App inherits Window {
        default-font-family: InterFont.family;
        default-font-size: KitMetrics.font-size(root.theme, TypographyRole.body);
        title: "Chip Button";
        preferred-width: 560px; preferred-height: 260px;
        max-width: 100000px; max-height: 100000px;
        in-out property <KitTheme> theme: KitThemeContext.current;
        background: root.theme.canvas;
        in property <OrderFilter> active: OrderFilter.awaiting-shipment;
        in property <string> status;
        callback choose(OrderFilter);
        VerticalLayout { padding: 24px; spacing: 20px; alignment: start;
            Text { text: "Filter the queue"; color: root.theme.text-primary; font-size: 22px * root.theme.text-scale; font-weight: 600; }
            Text { text: "Each chip shows one slice of the orders. The selected chip takes its status tone."; color: root.theme.text-secondary; wrap: word-wrap; }
            FlexboxLayout { spacing: root.theme.spacing.unit * 2; flex-wrap: wrap; alignment: start;
                KitChipButton { theme: root.theme; label: "All orders"; glyph: LucideIcons.inbox(); tone: Tone.accent; selected: root.active == OrderFilter.all; activated => { root.choose(OrderFilter.all); } }
                KitChipButton { theme: root.theme; label: "Awaiting shipment"; glyph: LucideIcons.package(); tone: Tone.information; selected: root.active == OrderFilter.awaiting-shipment; activated => { root.choose(OrderFilter.awaiting-shipment); } }
                KitChipButton { theme: root.theme; label: "In transit"; glyph: LucideIcons.truck(); tone: Tone.success; selected: root.active == OrderFilter.in-transit; activated => { root.choose(OrderFilter.in-transit); } }
                KitChipButton { theme: root.theme; label: "Delayed"; glyph: LucideIcons.clock(); tone: Tone.warning; selected: root.active == OrderFilter.delayed; activated => { root.choose(OrderFilter.delayed); } }
                KitChipButton { theme: root.theme; label: "Returned"; tone: Tone.danger; selected: root.active == OrderFilter.returned; activated => { root.choose(OrderFilter.returned); } }
            }
            result := Text { text: root.status; color: root.theme.text-secondary; }
        }
    }
    
    

    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.set_status("Showing orders awaiting shipment".into());
        app.on_choose(slint_kit::event(&app, |app, filter| {
            app.set_active(filter);
            app.set_status(format!("Showing {filter:?} orders").into());
        }));
        app.run()
    }
    
    

    Files: Cargo.toml · build.rs · ui/app.slint · src/main.rs

    Supply label, an optional glyph: IconGlyph, tone: Tone and selected. In a repeated list, bind token and generation to the row and handle activate(int, int) in the owning model, which decides the selection. A static chip may handle activated() instead, which replaces that identity report. A shortcut chip that only runs an action sets checkable to false.

    A selected chip takes its tone’s subtle fill and edge, a strong edge and a semibold label, so selection never rests on colour alone; otherwise it stays on the surface. A press reports the row it started on and is cancelled when token or generation changes before it ends. Screen readers announce a checkable chip as pressed or not pressed. A disabled chip emits nothing; its size follows control-size and enlarged text, and a touch host raises min-height to its own target.

    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
    Pressable chip for a status, filter or shortcut, with an optional icon and a tone.
    Browser capture of the same Slint example, femtovg renderer.
    // SPDX-License-Identifier: GPL-3.0-or-later
    import { InterFont } from "@kit-fonts/inter.slint";
    import { LucideIcons } from "@kit-icons/all.slint";
    import { KitChipButton, KitTheme, KitThemes, KitMetrics, Tone, TypographyRole } from "@kit";
    // A closed set the code owns: one variant per filter.
    enum OrderFilter { all, awaiting-shipment, in-transit, delayed, returned }
    export component Example inherits Window {
        default-font-family: InterFont.family;
        default-font-size: KitMetrics.font-size(root.theme, TypographyRole.body);
        title: "Chip Button";
        preferred-width: 560px; preferred-height: 260px;
        max-width: 100000px; max-height: 100000px;
        in-out property <KitTheme> theme: KitThemes.light;
        background: root.theme.canvas;
        in-out property <OrderFilter> active: OrderFilter.awaiting-shipment;
        VerticalLayout { padding: 24px; spacing: 20px; alignment: start;
            Text { text: "Filter the queue"; color: root.theme.text-primary; font-size: 22px * root.theme.text-scale; font-weight: 600; }
            Text { text: "Each chip shows one slice of the orders. The selected chip takes its status tone."; color: root.theme.text-secondary; wrap: word-wrap; }
            FlexboxLayout { spacing: root.theme.spacing.unit * 2; flex-wrap: wrap; alignment: start;
                KitChipButton { theme: root.theme; label: "All orders"; glyph: LucideIcons.inbox(); tone: Tone.accent; selected: root.active == OrderFilter.all; activated => { root.active = OrderFilter.all; } }
                KitChipButton { theme: root.theme; label: "Awaiting shipment"; glyph: LucideIcons.package(); tone: Tone.information; selected: root.active == OrderFilter.awaiting-shipment; activated => { root.active = OrderFilter.awaiting-shipment; } }
                KitChipButton { theme: root.theme; label: "In transit"; glyph: LucideIcons.truck(); tone: Tone.success; selected: root.active == OrderFilter.in-transit; activated => { root.active = OrderFilter.in-transit; } }
                KitChipButton { theme: root.theme; label: "Delayed"; glyph: LucideIcons.clock(); tone: Tone.warning; selected: root.active == OrderFilter.delayed; activated => { root.active = OrderFilter.delayed; } }
                KitChipButton { theme: root.theme; label: "Returned"; tone: Tone.danger; selected: root.active == OrderFilter.returned; activated => { root.active = OrderFilter.returned; } }
            }
        }
    }
    
    

    Download this example

    Public API

    Inherits KitPressable.

    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
    label string in —
    glyph IconGlyph in —
    tone Tone in Tone.neutral
    selected bool in —
    checkable bool in true
    token int in —
    generation int in —
    Available inherited properties
    Name Type Defined on Default
    theme KitTheme KitPressable KitThemeContext.current
    intent ButtonIntent KitPressable ButtonIntent.secondary
    control-size ControlSize KitPressable ControlSize.medium
    control-width ControlWidth KitPressable ControlWidth.intrinsic
    recipe ButtonRecipe KitPressable KitThemes.button-recipe(root.theme, root.intent, root.control-size)
    corner-radius length KitPressable root.recipe.radius
    padding-inline length KitPressable root.recipe.padding-inline
    padding-block length KitPressable root.recipe.padding-block
    text-size length KitPressable root.recipe.font-size
    text-weight int KitPressable root.recipe.font-weight
    accessible-name string KitPressable —
    description string KitPressable —
    disabled bool KitPressable —
    modal-layer int KitPressable —
    inert bool KitPressable —
    busy bool KitPressable —
    busy-label string KitPressable KitStrings.busy-label
    tab-stop bool KitPressable true
    activate-on-return bool KitPressable true
    form-submit-on-return bool KitPressable false
    pointer-enabled bool KitPressable true
    focus-on-pointer bool KitPressable true
    repeat-on-hold bool KitPressable —
    focus-indicated bool KitPressable —
    focus-ring KitFocusRing KitPressable root.recipe.focus
    hovered bool KitPressable —
    pressed bool KitPressable —
    has-focus bool KitPressable —
    focus-visible bool KitPressable —
    pointer-x length KitPressable —
    pointer-y length KitPressable —
    pointer-modifiers KeyboardModifiers KitPressable —

    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 typed controllers guide shows the Choices<K> source that feeds these properties.

    modal-layer int · in · defined on KitPressable

    The modal layer this control belongs to; 0 is the window. While a KitDialogSurface or KitDrawer with a positive modal-layer is open and topmost, every kit control whose modal-layer differs is inert: it takes no focus, ignores pointer and keys, and reports itself disabled to assistive technology. Give a control placed inside a modal that modal's layer number.

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

    form-submit-on-return bool · in · defined on KitPressable

    Let unmodified Return participate in an enclosing KitForm submission instead of activating this pressable. Outside a form, ordinary activation remains. Space keeps its normal action. This composition hook defaults to false; checkbox and switch compositions opt in.

    Default
    false.

    focus-on-pointer bool · in · defined on KitPressable

    Whether a primary pointer press focuses this primitive. Composite rows set false and focus their shared key scope instead, preserving navigation when a press is cancelled.

    Default
    true.
    KitPressable {
        focus-on-pointer: false;
    }

    repeat-on-hold bool · in · defined on KitPressable

    Repeat activated while the pointer stays pressed: first after the theme's motion.repeat-delay, then every motion.repeat-interval. A press that repeated activates nothing more on release; the repeat stops when the press ends or the control becomes disabled or busy. Keyboard activation does not repeat.

    Default
    false.
    KitPressable {
        repeat-on-hold: true;
    }

    Types and variants

    Type Declaration
    enum Tone neutral, accent, success, warning, danger, information

    Callbacks

    See also