Actively developed · Breaking changes are still expected.

Slint Kit Documentation

Search the documentation

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

    Display

    Avatar group for Slint

    KitAvatarGroup · Slint Kit 0.9.0

    Overlapping profile avatars with bounded visible members, per-member tones and an accessible overflow count.

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

    Overlapping profile avatars with bounded visible members, per-member tones and an accessible overflow count.
    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 Elliot Alderson or use Tab and Space: Rust resolves the stable profile key. Choose +1: the overflow action updates the status.

    ui/app.slint

    // SPDX-License-Identifier: GPL-3.0-or-later
    import { InterFont } from "@kit-fonts/inter.slint";
    import { KitAvatarGroup, AvatarEntry, AvatarInteraction, KitTheme, KitThemeContext, KitMetrics, TypographyRole } from "@kit";
    export component App inherits Window {
        default-font-family: InterFont.family;
        preferred-width: 540px; preferred-height: 260px;
        max-width: 100000px; max-height: 100000px;
        title: "Project members";
        in-out property <KitTheme> theme: KitThemeContext.current;
        in property <[AvatarEntry]> entries;
        in property <string> status: "Choose a member or +1.";
        callback profile-requested(int, int);
        callback more-requested();
        background: root.theme.canvas;
        VerticalLayout { padding: 24px; spacing: 20px; alignment: start;
            Text { text: "Project members"; color: root.theme.text-primary; font-size: KitMetrics.font-size(root.theme, TypographyRole.subtitle); }
            KitAvatarGroup { theme: root.theme; entries: root.entries; max-visible: 3; accessible-name: "Project members"; interaction: AvatarInteraction.action;
                activated(token, generation) => { root.profile-requested(token, generation); }
                overflow-activated => { root.more-requested(); }
            }
            Text { text: root.status; color: root.theme.text-secondary; font-size: KitMetrics.font-size(root.theme, TypographyRole.control); wrap: word-wrap; accessible-live-region: polite; }
        }
    }
    
    

    src/main.rs

    // SPDX-License-Identifier: GPL-3.0-or-later
    slint::include_modules!();
    use slint_kit::{KeyedModel, ui::{AvatarEntry, Tone}};
    #[derive(Clone, PartialEq, Eq, Hash)] struct ProfileId(u16);
    fn main() -> Result<(), Box<dyn std::error::Error>> {
        let app = App::new()?;
        slint_kit::install(&app);
        let rows = [(ProfileId(101), "Elliot Alderson", "EA", Tone::Accent), (ProfileId(203), "Darlene Alderson", "DA", Tone::Success), (ProfileId(307), "Angela Moss", "AM", Tone::Information), (ProfileId(409), "Tyrell Wellick", "TW", Tone::Warning)].into_iter().map(|(id, label, initials, tone)| (id, AvatarEntry { label: label.into(), initials: initials.into(), tone, ..Default::default() }));
        let members = KeyedModel::new(rows)?;
        app.set_entries(members.model());
        app.on_profile_requested(slint_kit::event2(&app, move |app, token, generation| { if let Some(id) = members.accept(token, generation) { app.set_status(format!("Profile #{} opened by Rust.", id.0).into()); } }));
        app.on_more_requested(slint_kit::action(&app, |app| app.set_status("More profiles requested by Rust.".into())));
        app.run()?; Ok(())
    }
    
    

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

    Provide AvatarEntry rows from KeyedModel<K, AvatarEntry> and resolve activated(token, generation) through accept before opening a profile. Set max-visible, avatar-size or exact size, and overlap. interaction defaults to static; action enables the member/overflow buttons. Handle overflow-activated separately.

    Only the visible members and optional overflow avatar mount. Replacing rows cancels held gestures; the host model rejects obsolete generations and disabled members. overflow-text and overflow-accessible-name are customizable; defaults use window KitStrings with singular/plural forms. Empty groups have zero intrinsic size. Status decorations on individual KitAvatar controls use its child slot; this bounded group renders its fixed AvatarEntry presentation.

    Control states

    Static members are images; action members and overflow use the shared pointer, keyboard, focus and disabled behavior. Source order remains Tab order in both directions; theme.direction mirrors positions. Empty groups have zero intrinsic geometry.

    Control accessibility

    Named group with member images or buttons and a separately named overflow. The full overflow name remains available when visible initials are elided. Qualify native screen readers separately.

    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
    Overlapping profile avatars with bounded visible members, per-member tones and an accessible overflow count.
    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 { KitAvatarGroup, AvatarInteraction, KitTheme, KitThemes, Tone } from "@kit";
    export component Example inherits Window {
        default-font-family: InterFont.family;
        preferred-width: 540px; preferred-height: 260px;
        max-width: 100000px; max-height: 100000px;
        title: "Project members";
        in-out property <KitTheme> theme: KitThemes.light;
        in-out property <string> status;
        background: root.theme.canvas;
        VerticalLayout { padding: 24px; spacing: 20px; alignment: start;
            Text { text: "Project members"; color: root.theme.text-primary; font-size: root.theme.typography.size-subtitle * root.theme.text-scale; }
            KitAvatarGroup { theme: root.theme; max-visible: 3; accessible-name: "Project members"; interaction: AvatarInteraction.action;
                entries: [{ token: 11, generation: 1, label: "Elliot Alderson", initials: "EA", tone: Tone.accent }, { token: 23, generation: 1, label: "Darlene Alderson", initials: "DA", tone: Tone.success }, { token: 37, generation: 1, label: "Angela Moss", initials: "AM", tone: Tone.information }, { token: 41, generation: 1, label: "Tyrell Wellick", initials: "TW", tone: Tone.warning }];
                activated(token, generation) => { root.status = "Profile " + token; }
                overflow-activated => { root.status = "More profiles requested"; }
            }
            Text { text: root.status; color: root.theme.text-secondary; font-size: root.theme.typography.size-control * root.theme.text-scale; wrap: word-wrap; accessible-live-region: polite; }
        }
    }
    
    

    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
    entries [AvatarEntry] in —
    interaction AvatarInteraction in AvatarInteraction.static
    overflow-interaction AvatarInteraction in root.interaction
    avatar-size AvatarSize in AvatarSize.medium
    size length in KitMetrics.avatar-size(root.theme, root.avatar-size)
    overlap length in root.theme.spacing.unit * 2 * root.theme.text-scale
    max-visible int in 5
    disabled bool in —
    accessible-name string in KitStrings.avatar-group-label
    overflow-text string in "+" + root.overflow-count
    overflow-accessible-name string in root.overflow-count == 1 ? KitStrings.avatar-more-singular : KitStrings.avatar-more-template.replace-all("{count}", "" + root.overflow-count)
    overflow-count int 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.

    entries [AvatarEntry] · in

    Typed AvatarEntry rows. Use KeyedModel<K, AvatarEntry> for process-unique tokens, the current generation and disabled-row acceptance guards. Each row carries label, initials, source, shape, tone and disabled state.

    Constraints
    Set shape and tone explicitly when needed; an omitted struct enum field uses its first variant.

    interaction AvatarInteraction · in

    AvatarInteraction.static exposes member images without Tab stops; .action exposes independent member buttons.

    Constraints
    Static is the default. Member callbacks carry the token and generation captured at activation start.

    overflow-interaction AvatarInteraction · in

    Controls the overflow avatar independently with the existing AvatarInteraction enum.

    Constraints
    Defaults to interaction.

    avatar-size AvatarSize · in

    Text-scaled avatar diameter preset from AvatarSize.

    Constraints
    Defaults to medium; an explicit size overrides the preset diameter.

    size length · in

    Exact diameter of each member and overflow avatar.

    Constraints
    Negative lengths clamp to zero. An explicit diameter stays fixed at 200% text, as with KitAvatar.

    overlap length · in

    Overlap between adjacent avatars, using theme spacing by default.

    Constraints
    Negative values behave as zero; overlap at or above the diameter gives a zero position step.

    max-visible int · in

    Maximum number of member rows mounted before the optional overflow avatar.

    Constraints
    Defaults to 5; zero or negative values show only overflow when entries are present. This keeps large source models bounded.

    disabled bool · in

    Disables every member and overflow action and applies the shared avatar disabled presentation.

    Constraints
    A row’s disabled state applies to that member independently.

    accessible-name string · in

    Accessible group name.

    Constraints
    Defaults to the window-local KitStrings.avatar-group-label.

    overflow-text string · in

    Visible text of the overflow avatar.

    Constraints
    Defaults to + followed by overflow-count. Supply compact text for unusually large counts if needed.

    overflow-accessible-name string · in

    Full accessible name of the overflow avatar, independent of its compact visible text.

    Constraints
    Defaults to localized KitStrings singular/plural templates, with {count} replaced by the hidden count.

    overflow-count int · out

    Read-only number of source rows beyond the visible member bound.

    Constraints
    Disabled rows still count as members; the host supplies the source order.

    Types and variants

    Type Declaration
    struct AvatarEntry token: int, generation: int, label: string, initials: string, source: image, shape: AvatarShape, tone: Tone, disabled: bool
    enum AvatarInteraction static, action
    enum AvatarShape circle, rounded, square
    enum AvatarSize compact, medium, large
    enum Tone neutral, accent, success, warning, danger, information

    Callbacks

    See also