Skip to content

feat: modernize RadioButton for MD3 - #5007

Open
burczu wants to merge 3 commits into
callstack:mainfrom
burczu:feat/radio-button-md3
Open

burczu wants to merge 3 commits into
callstack:mainfrom
burczu:feat/radio-button-md3

Conversation

@burczu

@burczu burczu commented Jun 19, 2026 •

Copy link
Copy Markdown

Motivation

RadioButton still shipped as two platform-specific implementations (RadioButtonAndroid, RadioButtonIOS) with the iOS variant rendering a checkmark glyph rather than a Material radio. This is inconsistent with the rest of the v6 MD3 work (Checkbox, Switch, TextInput, FAB) and diverges from the M3 radio button spec.

This PR unifies RadioButton into a single MD3 component that mirrors the modernized Checkbox structure (single component, tokens.ts, error prop, accessible={false} inner control), without pulling in Checkbox's reanimated/focus-ring machinery (out of scope — radio ships with none today).

Related issue

Closes #4938

What changed

  • Unified component — merged RadioButtonAndroid + RadioButtonIOS into a single MD3 RadioButton (Android impl as base). Dropped RadioButton.Android, RadioButton.IOS, RadioButtonIOS, and the RadioButton.Item mode prop.
  • Tokens — new RadioButton/tokens.ts (MD3 dims 20/10/2 + color roles); colors resolved via tokens in utils.
  • error prop — added to RadioButton and RadioButton.Item (ring + dot use theme.colors.error; disabled/custom colors take precedence).
  • Single animation path (reanimated) — collapsed two RN Animated.Values into one shared value and migrated to react-native-reanimated (matching Checkbox): dot scales in with overshoot on selection, keyed on checked so it also animates inside a RadioButton.Group. Uses theme.motion MD3 duration/easing tokens and respects reduce-motion.
  • Disabled opacity — the control now dims to 38% (selectionControlOpacity was previously computed but never applied).
  • Group perf — memoized the provider value + stabilized onValueChange with use-latest-callback; consumers switched from Context.Consumer to useContext.
  • Item a11y — inner control is accessible={false} + container importantForAccessibility="no-hide-descendants", so a screen reader sees one radio per row; dropped per-radio accessibilityLiveRegion; labelMaxFontSizeMultiplier=1.5 + ${testID}-text for CheckboxItem parity.
  • Docs/examples — updated examples (Group/Item, leading/trailing, error checked+unchecked, disabled); removed the iOS-mode demo and the RadioButtonAndroid/RadioButtonIOS doc pages.

Breaking changes

  • Removed RadioButton.Android, RadioButton.IOS, RadioButtonIOS (and RadioButtonAndroidProps/RadioButtonIOSProps exports).
  • Removed the RadioButton.Item mode prop.
  • error prop added (no visual change for existing usage).

Test plan

  • yarn typescript, yarn lint, yarn test (snapshots updated) — green.
  • yarn --cwd docs build — green.
  • Manually verified on iOS sim, Android emulator, and web: single selection, dot scale-in (standalone and in a Group), error (checked/unchecked), disabled dimming, leading/trailing, ripple, single a11y node per Item row.

Videos

radio_ios.mp4
radio_android.mp4
radio_web.mp4

@burczu
burczu marked this pull request as ready for review June 19, 2026 12:07
@burczu
burczu requested a review from satya164 June 19, 2026 12:15
@satya164
satya164 requested a review from Copilot June 28, 2026 16:21
@satya164

Copy link
Copy Markdown
Contributor

can you rebase the PR against main?

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.

Pull request overview

This PR modernizes RadioButton for Material Design 3 by replacing the prior platform-specific implementations with a single unified component, introducing MD3 token-based sizing/color resolution, and aligning behavior (animation, error/disabled states, a11y, and group performance) with the library’s other MD3 selection controls.

Changes:

  • Unifies RadioButton into a single MD3 implementation (removing RadioButton.Android, RadioButton.IOS, and the RadioButton.Item mode prop) and migrates selection animation to react-native-reanimated.
  • Adds MD3 radio tokens + error support, applies disabled opacity consistently, and updates selection-control color resolution to use tokenized theme roles.
  • Improves RadioButton.Group context stability and updates tests/examples/docs accordingly (including removing platform-specific docs pages).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/index.tsx Removes exported platform-specific RadioButton prop types.
src/components/RadioButton/utils.ts Updates selection-control color resolution to use RadioButton tokens and removes iOS-specific helper.
src/components/RadioButton/tokens.ts Introduces MD3 radio sizing + color-role tokens.
src/components/RadioButton/RadioButtonItem.tsx Removes mode, adds error, switches to useContext, and adjusts a11y/testID behavior.
src/components/RadioButton/RadioButtonGroup.tsx Memoizes context value and stabilizes onValueChange with use-latest-callback.
src/components/RadioButton/RadioButtonAndroid.tsx Deletes old Android-specific implementation.
src/components/RadioButton/RadioButtonIOS.tsx Deletes old iOS-specific implementation.
src/components/RadioButton/RadioButton.tsx Implements unified MD3 RadioButton with Reanimated dot-scale animation, tokenized sizes/colors, and updated a11y behavior.
src/components/RadioButton/index.ts Removes .Android/.IOS static exports from RadioButton.
src/components/tests/RadioButton/utils.test.tsx Updates tests to cover getSelectionControlColor including error/checked/unchecked cases.
src/components/tests/RadioButton/RadioButtonItem.test.tsx Removes platform-mode tests and adds a11y single-node assertion.
src/components/tests/RadioButton/RadioButtonGroup.test.tsx Adds test asserting stable context object across unrelated parent rerenders.
src/components/tests/RadioButton/RadioButton.test.tsx Simplifies snapshots to single unified RadioButton implementation.
src/components/tests/RadioButton/snapshots/RadioButtonItem.test.tsx.snap Updates snapshots for new unified control + a11y changes.
src/components/tests/RadioButton/snapshots/RadioButtonGroup.test.tsx.snap Updates snapshots for new unified control rendering.
src/components/tests/RadioButton/snapshots/RadioButton.test.tsx.snap Updates snapshots for unified control rendering.
example/src/Examples/RadioButtonItemExample.tsx Updates example to remove mode variants and demonstrate error/disabled states.
example/src/Examples/RadioButtonGroupExample.tsx Updates example usage to RadioButton (no platform statics).
example/src/Examples/RadioButtonExample.tsx Updates example states, adds error demos, and adjusts disabled label styling.
docs/versioned_docs/version-6.x/components/RadioButton/RadioButtonItem.mdx Removes documentation for the deleted mode prop.
docs/versioned_docs/version-6.x/components/RadioButton/RadioButtonIOS.mdx Removes iOS-specific docs page.
docs/versioned_docs/version-6.x/components/RadioButton/RadioButtonAndroid.mdx Removes Android-specific docs page.
docs/docusaurus.config.js Removes nav entries for the deleted platform-specific docs pages.

@burczu
burczu force-pushed the feat/radio-button-md3 branch from cb74fc8 to c0e1c18 Compare July 2, 2026 12:25
Comment thread src/components/RadioButton/tokens.ts Resolved

@MikitasK MikitasK 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.

  • updated radio-button state layer to MD3 specified 40dp size while keeping visible ring centered at 20dp
  • added reusable stateLayerSize token & removed previous margin-based state-layer sizing
  • made nested visual control inside RadioButton.Item non-focusable with focusable={false} and tabIndex={-1} keeping outer item as the only interactive radio
  • added regression coverage for 40dp state layer & updated affected accessibility & component snapshots

@JKobrynski

Copy link
Copy Markdown
Collaborator

@MikitasK is this ready for another review?

@JKobrynski JKobrynski 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.

Add a ### RadioButton entry to docs/6.x/docs/guides/migration.md. The iOS variant drew a checkmark, so anyone on it gets a visibly different control. #5059 has a ### Checkbox section covering the identical removals that would work as the template, but it skips RadioButton and still lists RadioButton.Android / RadioButton.IOS as live. Worth syncing with @mikolajadamowicz on which PR carries it.

@MikitasK

MikitasK commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Add a ### RadioButton entry to docs/6.x/docs/guides/migration.md. The iOS variant drew a checkmark, so anyone on it gets a visibly different control. #5059 has a ### Checkbox section covering the identical removals that would work as the template, but it skips RadioButton and still lists RadioButton.Android / RadioButton.IOS as live. Worth syncing with @mikolajadamowicz on which PR carries it.

done ✅ added ### RadioButton section following the structure used for Checkbox in #5059
@mikolajadamowicz this PR now carries RadioButton-specific migration guidance so we can avoid duplicating it in #5059

@JKobrynski JKobrynski 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.

We've got a bunch of conflicts

Comment thread src/utils/touchTarget.ts Resolved
@JKobrynski

Copy link
Copy Markdown
Collaborator

We've settled the 48dp question: controls grow to 48dp rather than getting an invisible tap area. Could touchTarget.ts go, with RadioButton growing its box like Checkbox does in #5104? The Checkbox change here can go too, since #5104 covers it.

@MikitasK

Copy link
Copy Markdown
Contributor

We've settled the 48dp question: controls grow to 48dp rather than getting an invisible tap area. Could touchTarget.ts go, with RadioButton growing its box like Checkbox does in #5104? The Checkbox change here can go too, since #5104 covers it.

updated RadioButton to use 48x48dp layout box instead of hitSlop. also removed touchTarget.ts, its tests & Checkbox changes covered by #5104

@satya164

Copy link
Copy Markdown
Contributor

Review by Claude

The press and hover state layer covers the whole 48dp touch target. The MD3 radio state layer is 40dp, and the new 40dp stateLayer view in RadioButton.tsx paints nothing. Each screenshot shows the "Error (Checked)" radio on the Radio Button example screen.

iOS

Steps: open Radio Button, press and hold the "Error (Checked)" radio.
What happens: the highlight is a 48pt circle around the 20pt ring.
What should happen: a 40pt state layer, as the spec and Checkbox use.

iOS, pressed: 48pt highlight

(via Claude, verify if it makes sense)

Android

Steps: open Radio Button, press and hold the "Error (Checked)" radio.
What happens: the ripple is a 48dp circle (126px at 2.625x density).
What should happen: a 40dp ripple.

Android, pressed: 48dp ripple

(via Claude, verify if it makes sense)

Web

Steps: open /radio, hover the "Error (Checked)" radio.
What happens: the hover overlay is a 48px circle.
What should happen: a 40px state layer.

Web, hovered: 48px overlay

(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

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

Comment thread docs/6.x/docs/guides/migration.md Resolved
Comment thread docs/src/data/screenshots.ts Resolved
@MikitasK

MikitasK commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review by Claude

The press and hover state layer covers the whole 48dp touch target. The MD3 radio state layer is 40dp, and the new 40dp stateLayer view in RadioButton.tsx paints nothing. Each screenshot shows the "Error (Checked)" radio on the Radio Button example screen.

iOS

Steps: open Radio Button, press and hold the "Error (Checked)" radio. What happens: the highlight is a 48pt circle around the 20pt ring. What should happen: a 40pt state layer, as the spec and Checkbox use.

iOS, pressed: 48pt highlight

(via Claude, verify if it makes sense)

Android

Steps: open Radio Button, press and hold the "Error (Checked)" radio. What happens: the ripple is a 48dp circle (126px at 2.625x density). What should happen: a 40dp ripple.

Android, pressed: 48dp ripple

(via Claude, verify if it makes sense)

Web

Steps: open /radio, hover the "Error (Checked)" radio. What happens: the hover overlay is a 48px circle. What should happen: a 40px state layer.

Web, hovered: 48px overlay

(via Claude, verify if it makes sense)

good catch, thanks 🙏
fixed that ☑️

image image

@Doberjohn Doberjohn added this to the 6.0.0 milestone Oct 30, 2026
@Doberjohn

Copy link
Copy Markdown
Collaborator

This also fixes #4775 (the duplicate tab stop in RadioButton.Item), so could you add Fixes #4775 to the description? #5050 has the same fix and closes when this merges.

@MikitasK

MikitasK commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

This also fixes #4775 (the duplicate tab stop in RadioButton.Item), so could you add Fixes #4775 to the description? #5050 has the same fix and closes when this merges.

nice finding 👍
the only thing is that I don't have permission to edit this PR's description since @burczu is the owner
@burczu when you'd have time, could you pls update PR description according to @Doberjohn comment 🙏

@Doberjohn Doberjohn added the needs pickup Work that has been started but needs someone to pick it up and continue. label Nov 18, 2026
@Doberjohn Doberjohn removed the needs pickup Work that has been started but needs someone to pick it up and continue. label Nov 18, 2026
@jacekAtCK

Copy link
Copy Markdown
Collaborator

/review

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot 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.

Apex Sentinel: 3 new findings on e51f07f. The verdict and the full list are in the summary comment.

Comment thread docs/component-docs.config.ts Resolved
Comment thread docs/src/data/screenshots.ts Resolved
@jacekAtCK
jacekAtCK force-pushed the feat/radio-button-md3 branch from e51f07f to 533580d Compare November 23, 2026 00:58
@jacekAtCK
jacekAtCK requested a review from JKobrynski November 23, 2026 01:04
@jacekAtCK

Copy link
Copy Markdown
Collaborator

/review

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 533580d

Since the review of e51f07f: 1 new · 0 still open · 3 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
src/components/RadioButton/RadioButtonItem.tsx:203 🆕 RadioButton.Item row never activates on Space on web, unlike Checkbox.Item
Not in the reviewers' prompt (3 files)
  • src/components/__tests__/RadioButton/__snapshots__/RadioButton.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/RadioButton/__snapshots__/RadioButtonGroup.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/RadioButton/__snapshots__/RadioButtonItem.test.tsx.snap: generated or a lockfile, so its lines were left out

2 findings below minor hidden (user_settings.min_severity).

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

💬 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.

@apex-sentinel-staging apex-sentinel-staging Bot 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.

Apex Sentinel: 1 new finding on 533580d. The verdict and the full list are in the summary comment.

@jacekAtCK
jacekAtCK force-pushed the feat/radio-button-md3 branch from 533580d to 3e94023 Compare November 23, 2026 22:28

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.

refactor(radio-button): modernize selection model and improve MD3 compliance

7 participants