Skip to main content

CamoIconButton

Concept​

1. Why​

Icon-only actions (back, close, more, favorite) are everywhere in top bars and cards, and they're the most common accessibility failure: a tappable icon with no label. CamoIconButton makes the label required, takes the icon as a widget (your AppIcon.back()), and applies the same appearance, tone and feedback model as CamoButton in a compact, usually circular shape.

2. Shape​

Material mapping preview

AppearanceMaterial 3 icon buttonContainerIcon
SolidFilledf.strongf.onStrong
SoftFilled tonalf.containerf.onContainer
OutlineOutlinedtransparent + outline borderonSurfaceVariant (f.strong for status tones)
Ghost (default)StandardtransparentonSurfaceVariant (f.strong for status tones)

Raised falls back to Soft, and Link to Ghost (Design Language §3.3).

3. API​

Contract​

fun CamoIconButton(
icon: Widget, // usually an app icon widget
contentDescription: String, // required, non-null: describes the action
onClick: () -> Unit,
appearance: Appearance? = null, // null → IconButtonTheme.defaultAppearance (skin default: Ghost)
tone: Tone = Default, // e.g. Error for a delete icon
enabled: Boolean = true,
checked: Boolean? = null, // non-null → a toggle button (favorite, bookmark): toggle role + selected look
loading: Boolean = false, // a progress circle replaces the icon
tooltip: String? = null, // a CamoTooltip on hover / focus / long-press (see Overlays › CamoTooltip)
)

The default appearance is Ghost, because most icon buttons sit in bars and should stay quiet. tone works as it does on CamoButton (a red trash icon is tone = Error).

State → renderer: IconButtonState(enabled, checked?, loading, appearance, tone, interaction). Slots: IconButtonSlots(icon). Core marks the icon's own semantics as hidden, because the button carries the label.

Tokens used​

  • the colors in the mapping table, and the disabled alphas on onSurface
  • shapes.full
  • the ambient icon style size 24, inside a 40 visual container; the touch target is 48

Component theme​

theme.components.iconButton: IconButtonTheme?. 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
defaultAppearanceAppearanceGhostthe appearance used when a call passes none (ADR-28: a brand's default variant)
containerSizeDp40visual size of the container (the touch target stays at least 48)
shapeShapeshapes.fullcontainer shape
iconSizeDp24the ambient icon size for icon
solidColors / softColors / outlineColors / ghostColorsIconButtonColors(container, content, border?)per the table abovecolors per appearance for tone = Default
checkedColorsIconButtonColorsMaterial: f.strong / f.onStrong (selected filled); Minimal: surfaceContainerHigh / inkthe look when checked = true

Accessibility​

  • Role button, with the label contentDescription. With checked non-null: a toggle button with an on/off state ("Favorite, toggle button, on").
  • loading: busy semantics, focus kept, clicks ignored (as on CamoButton).
  • The 48 × 48 touch target is enforced even though the visual container is 40.
  • The label describes the action ("Close", "Add to favorites"), not the icon ("X", "Heart").

4. Build steps​

  1. Core: the same interaction and clickable wiring as CamoButton, with the label from contentDescription. Clear the icon's own semantics.
  2. DebugSkin renderer: a circle; set an icon style; place the icon.
  3. Sample: a top-bar-style row of three icon buttons (one per appearance) using AppIcons, one of them disabled.
  4. Tests: the toggle role and on/off state when checked is set; loading swaps the icon for a progress circle and ignores clicks; the label is exposed; the target is at least 48; the icon has no own semantics node; an AppIcon with no parameters takes size 24 and the appearance's content color; disabled blocks the click.

Done when

  • Every icon button in the sample is announced by its action label.
  • Appearances are distinct on MinimalSkin, and the icons follow them with no parameters.

5. Edge cases​

CaseDecided behavior
A toggle icon button (settled 2026-09-27)checked = true/false. The app still passes the icon for the state (outline heart / filled heart), matching the icon-widget pattern, and keeps onClick as the only callback (it flips its own state). The skin draws checkedColors. It passes ADR-23 (Fluent ToggleButton, Carbon selected icon button, Apple toggle buttons).
contentDescription of a toggleDescribes the action, and stays the same in both states ("Favorite"); the toggle state is announced separately.
Directional icons (back) in RTLThe app icon uses IconSource(autoMirror = true).
Font scale 200%The icon doesn't scale. The target stays 48.
Something other than an icon passed as icon (an avatar image)It's allowed and gets the 24 box. Colors are the app's responsibility.
Several icon buttons tightly packedThe platform resolves the nearest target. The design guideline is spacing.s between them.

Implementation​

1. Why​

This is the icon-only action. It's the button skeleton with a required label, a small visual container (40 dp) inside a 48 dp touch target, and the icon slot's own semantics cleared, because the button speaks for it.

2. Shape​

3. API​

@Composable
public fun CamoIconButton(
icon: @Composable () -> Unit,
contentDescription: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
appearance: Appearance? = null, // null → IconButtonTheme.defaultAppearance
tone: Tone = Tone.Default,
enabled: Boolean = true,
checked: Boolean? = null, // non-null → a toggle button (toggleableState semantics, see §5)
loading: Boolean = false,
tooltip: String? = null, // CamoTooltip: hover/focus on desktop and web, long-press on touch
interactionSource: MutableInteractionSource? = null,
)

IconButtonTheme / IconButtonStyle are containerSize, shape, iconSize, borderWidth and per-appearance IconButtonColors (Solid, Soft, Outline, Ghost), with the same colorsFor(appearance, tone, theme) logic as buttons (Ghost + Default → onSurfaceVariant content). Core applies the fallbacks first: Raised → Soft, Link → Ghost.

The icon is wrapped in Modifier.clearAndSetSemantics {} inside the renderer's slot container. That guarantees one announcement ("Back, button") even if the app's icon composable sets its own description.

4. Build steps​

  1. Types in core/iconbutton/, the component, and the DebugSkin renderer.
  2. commonTest:
    • onNodeWithContentDescription("Back") has Role.Button;
    • there's exactly one node with that description;
    • the touch bounds are 48 × 48 while the visual box is 40;
    • the icon takes iconSize and the appearance's content color without parameters.

Done when

  • A top-bar-like row of three icon buttons works with touch, mouse, Tab + Enter, and a screen reader.

5. Edge cases​

CaseDecided behavior
An app icon composable with its own contentDescriptionCleared by the slot wrapper, so there's no double announcement.
Tooltiptooltip in v1 on every target (base decision): core's CamoTooltip, not Material's TooltipBox.
checked semanticsModifier.semantics { role = Role.Button; toggleableState = ToggleableState(checked) } so TalkBack/VoiceOver announce "toggle button, on".
containerSize > 48 in the themeThe touch target grows with it (minimumTouchTarget is a minimum).