Skip to content
Glint UI

ToggleGroup

A strip of toggles that acts as one control — pick one, or pick several.

Usage

import { ToggleGroup } from "@glint/components/toggle-group.slint";
import { IconSet } from "@lucide";
export component AppWindow inherits Window {
in-out property <int> view-mode: 0;
VerticalLayout {
alignment: center;
ToggleGroup {
selected <=> root.view-mode;
items: [
{ label: "Grid View", icon: IconSet.LayoutGrid },
{ label: "List View", icon: IconSet.List },
];
changed(index) => {
// handle mode change
}
}
}
}

ToggleGroup renders a cohesive set of mutually exclusive toggle buttons (for single choice) or independent toggle buttons (using ToggleGroupMultiple for multi-selection toolbars).

Examples

Variants

variant applies styling to all items in the group:

  • ToggleGroupVariant.default: Clean background with accent highlight on active items.
  • ToggleGroupVariant.outline: Bordered item frames.

Sizes

size configures item height and density:

  • ToggleGroupSize.sm: Compact height (28px).
  • ToggleGroupSize.default: Standard height (36px).
  • ToggleGroupSize.lg: Larger height (40px).

Orientations

The orientation property arranges items horizontally or vertically:

  • ToggleGroupOrientation.horizontal: Row layout (default).
  • ToggleGroupOrientation.vertical: Stacked column layout.

Multi-selection formatting toolbar

Use ToggleGroupMultiple when multiple toggles can be active simultaneously (such as rich text formatting with Bold, Italic, and Underline).

API Reference

Properties

PropertyTypeDefaultDescription
itemsin [ToggleGroupItem]no defaultToggles shown in the group.
selectedin-out int0Two-way; index of the active toggle.
orientationin ToggleGroupOrientationToggleGroupOrientation.horizontalhorizontal (default) or vertical.
variantin ToggleGroupVariantToggleGroupVariant.defaultVisual style, handed to every item — default or outline.
sizein ToggleGroupSizeToggleGroupSize.defaultDensity, handed to every item — sm, default, lg.
disabledin boolfalseTakes the whole group away — the toolbar of a read-only document. An item may also refuse on its own; see ToggleGroupItem.disabled.

Callbacks

CallbackDescription
changed(int)Fired with the new selected index.

Enums

EnumValues
ToggleGroupOrientationhorizontal, vertical
ToggleGroupVariantdefault, outline
ToggleGroupSizesm, default, lg

ToggleGroupMultiple

Multi-selection variant for toolbars where multiple buttons can be active simultaneously.

Properties

PropertyTypeDefaultDescription
itemsin-out [ToggleGroupItem]no defaultToggles shown in the group. Two-way, because on is the state and it lives in the item — see ToggleGroupItem.on for why it is not a list of flags beside this one.
focusedin-out int0Two-way; where the keyboard stands. Not a selection: what it points at is what Space flips.
orientationin ToggleGroupOrientationToggleGroupOrientation.horizontalhorizontal (default) or vertical.
variantin ToggleGroupVariantToggleGroupVariant.defaultVisual style, handed to every item — default or outline.
sizein ToggleGroupSizeToggleGroupSize.defaultDensity, handed to every item — sm, default, lg.
disabledin boolfalseTakes the whole group away — the toolbar of a read-only document. An item may also refuse on its own; see ToggleGroupItem.disabled.

Callbacks

CallbackDescription
toggled(int)Fired with the index of the item that flipped. Read items[index].on for which way it went.

Enums

EnumValues
ToggleGroupOrientationhorizontal, vertical
ToggleGroupVariantdefault, outline
ToggleGroupSizesm, default, lg

Accessibility

  • Radio group vs Groupbox. ToggleGroup publishes accessible-role: radio-group with radio-button items. ToggleGroupMultiple publishes accessible-role: groupbox with checkbox items.
  • Focus delegation in ToggleGroupMultiple. Its accessible-delegate-focus ensures screen readers announce the currently focused item when traversing. ToggleGroup does not set this property.
  • Keyboard navigation. In ToggleGroup, arrow keys move and commit the selection. In ToggleGroupMultiple, arrow keys move focus without committing and Space or Enter toggles the focused item.