Skip to content

feat(icon button)!: refactor icon button component - #5103

Merged
Doberjohn merged 21 commits into
mainfrom
feat/refactor-icon-button-component
Nov 20, 2026
Merged

Doberjohn merged 21 commits into
mainfrom
feat/refactor-icon-button-component

Conversation

@alpharius-ck

@alpharius-ck alpharius-ck commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Brings IconButton in line with Material 3 Expressive: five sizes, narrow/default/wide widths, round/square shapes that morph on press and toggle, filled/tonal/outlined/standard colors, and a 0.10 disabled opacity.

Related issue

https://app.notion.com/p/callstack/Modernize-IconButton-to-Material-3-Expressive-3ac5d027c0f880fcb083e5a909d4d82b

Test plan

Checked the example app on web, iOS and Android.

Screenshots / Videos


BREAKING CHANGE: IconButton's size is now a named size (extra-small to extra-large, with iconSize for the glyph), the contained and contained-tonal modes are renamed filled and tonal, and Appbar.Action and Appbar.BackAction no longer take a numeric size.

# Conflicts:
#	src/components/IconButton/IconButton.tsx
#	src/components/IconButton/utils.ts
#	src/components/TextInput/TextInputIcon.tsx
alpharius-ck and others added 2 commits September 8, 2026 10:53
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@satya164
satya164 requested a balanced review from Copilot September 15, 2026 20:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: Cursor <cursoragent@cursor.com>
@satya164

Copy link
Copy Markdown
Contributor

Review by Claude

iOS

  1. The toggle shape ends up inverted after a quick tap.
    Steps: open the Icon Button example, tap the first Playground button once, then tap it again.
    What happens: the selected button stays round. The unselected button turns square.
    What should happen: a round button turns square when selected and goes back to round when unselected, as it does on web.
    iOS: toggle shape after a quick tap
    (via Claude, verify if it makes sense)

  2. Removing the 6dp margin from IconButton moves the icon buttons in Appbar, Searchbar and DataTable.Pagination.
    Steps: open the Appbar, Searchbar and Data Table examples and compare with main.
    What happens: the back icon and the title move toward the edge, the trailing actions and the bottom bar actions touch each other, the Searchbar icon and text move left, and the pagination arrows sit closer together.
    What should happen: these components keep their spacing, or get the spacing from the Material spec.
    iOS: Appbar on main and on this PR
    iOS: Searchbar on main and on this PR
    iOS: DataTable pagination on main and on this PR
    (via Claude, verify if it makes sense)

Android

  1. The same toggle shape bug as on iOS.
    Steps: open the Icon Button example, tap the first Playground button once, then tap it again.
    What happens: the selected button stays round. The unselected button turns square.
    What should happen: a round button turns square when selected and goes back to round when unselected.
    Android: toggle shape after a quick tap
    (via Claude, verify if it makes sense)

@satya164 satya164 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Claude

  • The migration guide (docs/6.x/docs/guides/migration.md) has no IconButton section for these breaking changes: mode="contained" to "filled" and "contained-tonal" to "tonal", the numeric size replaced by named sizes, size removed from Appbar.Action and Appbar.BackAction, selected={false} now picking the toggle-off colors (for example filled turns surfaceContainer instead of primary), the removed 6dp margin, and Card.Title right props that can no longer be spread into IconButton. JavaScript users who still pass size={24} get a crash, because IconButtonTokens.sizes[24] is undefined and getDimensions reads spec.widths. Please add before and after snippets for each.

See the inline comments for the rest. (via Claude, verify if it makes sense)

Comment thread package.json Resolved
Comment thread docs/src/data/screenshots.ts Resolved
Port main's IconButton changes into the Material 3 Expressive rewrite:
- 48dp hit slop via getMinInteractiveSizeHitSlop, with a hitSlop override
  (none when disabled or without a touch handler)
- role prop, and an image role on web for a labelled, handler-less button
- touchable fills the container so content stays centered
- touchable clips its own ripple, so the hit slop is not clipped
- a disabled icon takes the disabled color over iconColor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Doberjohn

Copy link
Copy Markdown
Collaborator

Heads-up: #5107 is merged, and it moves every focus ring onto one shared hook, src/utils/useFocusRing.ts. Merging main here now conflicts in FAB/Menu.tsx, FAB/Shell.tsx, IconButton/IconButton.tsx and TextInput/TextInputIcon.tsx. When you update the branch:

  • Drop src/utils/focusRing.ts and take main's side in the FAB files.
  • Drop IconButton's own focus state and ring view: its TouchableRipple already draws the ring, so keeping both shows two.
  • Keep the theme props feat: add MD3 keyboard focus indicators #5107 added on IconButton's TouchableRipple and TextInput.Icon's IconButton.

If the outline now sits outside the touchable, ring the container the way Button does (useFocusRing with 'within').

@Doberjohn

Copy link
Copy Markdown
Collaborator

The branch is 46 commits behind and has conflicts, so it needs a rebase anyway. Regenerate the snapshots afterwards.

Take main's shared keyboard focus ring (#5107):
- drop src/utils/focusRing.ts and take main's FAB, Switch and Checkbox
- drop IconButton's own focus state and ring view; the ring now comes from
  useFocusRing with 'within' on the clip view, so it surrounds the outline
  and the touchable no longer draws a second one
- keep the theme props on IconButton's TouchableRipple and TextInput.Icon
- regenerate snapshots, add IconButton focus ring wiring tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@alpharius-ck
alpharius-ck removed the request for review from satya164 November 16, 2026 14:37
A disabled filled, tonal or outlined-selected button takes the disabled
container color and ignores `containerColor`, as in 5.x. Note it on the prop
and in the migration guide, and cover it with a test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@Doberjohn

Copy link
Copy Markdown
Collaborator

Two more small things and we are ready to merge:

  1. Derived test IDs IconButton.tsx passes ${testID}-container to the container and ${testID}-icon to the icon. v6 removed derived test IDs on purpose in fix: remove derived testIDs #5099, and the migration guide's Test IDs section says they are gone. Please drop both, and move the tests that use icon-button-container to the touchable's testID or to role and label queries. The IconButton and Appbar snapshots then lose icon-button-container, icon-button-icon, appbar-action-container and appbar-action-icon.

  2. BREAKING CHANGE: paragraph. The title has !, but the description has no BREAKING CHANGE: paragraph for the squash message. One sentence for users is enough, for example:

    BREAKING CHANGE: IconButton's `size` is now a named size (`extra-small` to `extra-large`, with `iconSize` for the glyph), the `contained` and `contained-tonal` modes are renamed `filled` and `tonal`, and `Appbar.Action` and `Appbar.BackAction` no longer take a numeric `size`.
    

@Stoneski93 Stoneski93 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against the M3 spec: sizes, shapes, colors and touch target match. The color, spring and test ID fixes look good.

Open (inline): the state layer is a circle in the pressed square (web), outlined ripple corner (nit), and style.borderRadius ignored without docs.

Tested on web and Android.

- give the touchable and the disabled layer the container corner less the
  outline, morphing with it
- make the web ripple container inherit the touchable's corner so a held
  press fills the whole container
- document that `borderRadius` in `style` is ignored
- stop `TextInput.Icon` accepting an `iconSize` it ignores

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@Doberjohn

Copy link
Copy Markdown
Collaborator

#5218 is in main now, so this PR will need main merged in when it's next in its lane (no need before then). I tried the merge locally: Git only conflicts in the Appbar and TextInput snapshots, but AppbarAction.tsx merges cleanly and then fails the typecheck:

src/components/Appbar/AppbarAction.tsx(134,7): error TS2322: Type 'Mode | "contained" | "contained-tonal" | undefined' is not assignable to type 'Mode | undefined'.

variantIconButtonModes (AppbarAction.tsx:151 on main) still maps filled and tonal to contained and contained-tonal. After the rename here, variant takes the same values as IconButton's mode, so the map can go, and width="wide" could pass IconButton's new width instead of the fixed 52 in styles.wide.

`filled` and `tonal` are now IconButton modes too, so the map is gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@Doberjohn

Copy link
Copy Markdown
Collaborator

Two small things for loading, to match Button in #5225:

  1. Mark the button itself busy while loading (busy on the pressable, the indicator hidden from assistive technology). On Android pass busy as true or false, never undefined, or TalkBack keeps saying "busy" after loading ends.
  2. A JSDoc line on loading saying it doesn't disable the button, so apps pass disabled too if presses should be ignored.

Set `aria-busy` on the button, always as a boolean so TalkBack stops saying
"busy" once loading ends, and hide the indicator from assistive technology.
Document that `loading` doesn't disable the button.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

A hidden ActivityIndicator stays an accessible view, and on Android an
accessible view is a keyboard stop. A loading IconButton had a second,
invisible Tab stop on its indicator. ActivityIndicator now drops
`accessible` when it gets `aria-hidden`.
The migration guide's code comments and the `mode` JSDoc used em
dashes; they now use colons.
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of e4ebd6b

Since the review of 7764be7: 0 new · 0 still open · 0 no longer raised

No open findings.

Not in the reviewers' prompt (17 files)
  • docs/public/screenshots/icon-button-1.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-2.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-3.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-4.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-filled.android.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-filled.ios.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-outlined.android.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-outlined.ios.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-standard.android.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-standard.ios.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-tonal.android.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/icon-button-tonal.ios.png: no text diff (a binary, empty or mode-only change)
  • src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/DataTable.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/IconButton.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/TextInput.test.tsx.snap: generated or a lockfile, so its lines were left out

Reviewed with this repository's own Sentinel configuration (add03a126630).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@Doberjohn
Doberjohn merged commit 86b9988 into main Nov 20, 2026
14 checks passed
@Doberjohn
Doberjohn deleted the feat/refactor-icon-button-component branch November 20, 2026 14:49
@Doberjohn
Doberjohn restored the feat/refactor-icon-button-component branch November 20, 2026 14:58
@Doberjohn
Doberjohn deleted the feat/refactor-icon-button-component branch November 20, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants