Skip to content

feat: refactor icon button component - #5103

Open
alpharius-ck wants to merge 10 commits into
mainfrom
feat/refactor-icon-button-component
Open

alpharius-ck wants to merge 10 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 onto the M3 Expressive spec: XS–XL sizes, narrow/default/wide widths, round/square shapes with press and toggle morph, standard/filled/tonal/outlined colors with a separate toggle-off set, and 0.10 disabled container opacity. Tokens live with the component and reuse theme shape, color and motion tokens. It also uses the shared focus ring and the 48dp touch target from main.

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


# 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
@alpharius-ck
alpharius-ck requested review from Doberjohn and removed request for JKobrynski November 16, 2026 14:37

This branch has not been deployed

No deployments
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.

4 participants