Skip to main content

CamoButtonGroup

Concept​

1. Why​

A button group puts related buttons together as one control: a set of commands (Cut, Copy, Paste), or a set of toggles (Bold, Italic, Underline) in an editor (Material button groups, Fluent's button set). It is not a segmented control: a segmented control chooses one value for a setting ('Day / Week / Month'); a button group runs commands or toggles independent flags. connected groups share borders and corners; spaced groups keep a gap.

2. Shape​

Split of duties

CoreSkin (renderer)
the button model, selection mode (none or multiple, or single for a one-of toggle row), roving focus and the group role, position for each button's "2 of 3" and shapethe container, each button's look by position (rounded ends, shared borders), the selected look, spacing

Material mapping preview: the M3 button groups.

  • Connected: buttons share a 1 dp border; only the outer ends are fully rounded; the pressed or selected button becomes primary-filled and rounder.
  • Spaced (standard): spacing.xs gap between independent buttons.

3. API​

Contract​

data class CamoGroupButton(
val key: Any,
val text: String? = null,
val icon: Widget? = null, // needs a contentDescription when there is no text
val contentDescription: String? = null,
val onClick: () -> Unit,
val selected: Boolean? = null, // non-null → a toggle
val enabled: Boolean = true,
)

fun CamoButtonGroup(
buttons: List<CamoGroupButton>,
connected: Boolean = true,
appearance: Appearance? = null, // null → ButtonGroupTheme.defaultAppearance (skin default: Outline)
tone: Tone = Default,
enabled: Boolean = true,
)

Each button reports its position (first, middle, last, only) so the renderer can round the outer corners of a connected group.

State → renderer: ButtonGroupState(count, connected, appearance, tone, enabled) for the container and GroupButtonState(selected, enabled, position, appearance, tone, interaction) for each button. Slots: GroupButtonSlots(text?, icon?).

Tokens used​

  • the tone family; outline, outlineVariant, primary / onPrimary (selected)
  • shapes.full (Material's end rounding), shapes.small (Minimal and Fluent corners)
  • typography.labelLarge, spacing.xs (spaced gap), icons 18 to 24
  • motion.durationShort (the selected fill)

Component theme​

theme.components.button group: ButtonGroupTheme?. Every field is nullable in the theme. The skin's defaults(theme) fills whatever isn't set (Material defaults shown). See Theme §3.10.

FieldTypeMaterial defaultWhat it's for
defaultAppearanceAppearanceOutlinethe appearance when a call passes none (ADR-28)
heightDp40button height
shapeShapeshapes.fullthe outer corners
innerShapeShapeshapes.extraSmallthe corners between connected buttons
spacingDp2the gap in a spaced group
borderWidthDp1shared borders
iconSize / iconGapDp18 / 8icon and label
textStyleCamoTextStylelabelLargelabels
colorsGroupColors(content, border, selectedContainer, selectedContent)M3 valuesevery color it uses

Accessibility​

  • A group named by the app; each button is a button, and a toggle announces "Bold, toggle button, pressed" ("2 of 3").
  • One Tab stop; the arrows move between enabled buttons (wrapping); Space and Enter activate.
  • Icon-only buttons need a contentDescription (a debug assertion).

4. Build steps​

  1. CamoGroupButton, ButtonGroupTheme / Style, state, slots, renderer, the CamoSkin field.
  2. CamoButtonGroup, the DebugSkin renderer.
  3. Tests: commands fire; toggles keep the app's selected; roving focus; positions and shapes (first, middle, last); disabled; the assertion for an icon-only button without a description.

Done when

  • An editor's Bold / Italic / Underline group and a Cut / Copy / Paste group work by touch, keyboard and screen reader.

5. Edge cases​

CaseDecided behavior
One buttonA group of one: its own position only.
WrappingA group never wraps; too many buttons belong in a toolbar's overflow.
Single-select toggles ("align left / center / right")Allowed: the app keeps one selected true; for a setting-like choice prefer the segmented control.
RTLOrder and end rounding mirror.
Changed in the M9 build (2026-11-02)
  • ButtonGroupState(count, connected, appearance, tone, enabled) for the container and GroupButtonState(selected, enabled, position, connected, appearance, tone, interaction) for each button; GroupColors has one set for the default tone, and other tones use their family's strong color.
  • The renderer has two parts, the container and the button. A connected Outline group shares one outline: Kotlin overlaps the buttons' borders by one border width, Flutter draws one outline with lines between the buttons. Appearances: Outline is bordered and transparent, Ghost and Link are transparent, Soft, Solid and Raised are filled; a pressed toggle takes selectedContainer.
  • Core owns the interaction: one Tab stop, the arrow keys move focus (wrapping, skipping disabled buttons) and do not press, Space and Enter press. An icon-only button without a description fails a debug check.
  • Not built: the container and button as ADR-30 building blocks, a built-in selection helper, and a rounder pressed shape.
  • Selection modes: v0.1 has commands and independent toggles only; the app owns selected. A built-in single or multiple selection helper (like CamoChipGroup) can come with the sample if you want it.

Implementation​

1. Why​

A Row of skin-drawn buttons with a group role and roving focus, built from the same pieces as the segmented control (ItemPosition, rememberRovingFocus), with Role.Button and toggleable instead of radio semantics.

2. Shape​

3. API​

@Composable public fun CamoButtonGroup(buttons: List<CamoGroupButton>, modifier: Modifier = Modifier,
connected: Boolean = true, appearance: Appearance? = null, tone: Tone = Tone.Default, enabled: Boolean = true)
  • The container is selectableGroup-free (it is not a single choice): Modifier.semantics { collectionInfo } and arrow-key roving focus.
  • A toggle is toggleable(role = Role.Checkbox) announced as a toggle button (ToggleableState); a command is clickable(role = Role.Button).

4. Build steps​

  1. The group, ButtonGroupTheme / Style, state, slots, renderer, the CamoSkin field, the DebugSkin renderer.
  2. Tests: commands, toggles, arrows, positions, semantics.

Done when

  • The groups work by touch, keyboard and screen reader on all targets.

5. Edge cases​

CaseDecided behavior
Touch targetEach button keeps the 48 target through minimumTouchTarget even when the visual is 40.
Changed in the M9 build (2026-11-02)
  • CamoGroupButton(key, onClick, text, icon, contentDescription, selected, enabled); a command is a clickable and a toggle a toggleable, both with the button role (a toggle announces its state). The group carries collection info ("2 of 3") and contentDescription names it.
  • Roving focus is rememberRovingFocus with rovingFocusItem(…, onSelect = {}), so the arrows move without selecting. Tests: commands, toggles, positions, arrows (skipping a disabled button), the disabled group, the icon-only check.
  • None specific.