Skip to content

Add AccessibilityInfo.isOnOffSwitchLabelsEnabled on iOS - #59179

Open
camilopires wants to merge 1 commit into
react:mainfrom
camilopires:a11y/ios-on-off-switch-labels
Open

camilopires wants to merge 1 commit into
react:mainfrom
camilopires:a11y/ios-on-off-switch-labels

Conversation

@camilopires

Copy link
Copy Markdown
Contributor

Summary:

On/Off Labels adds I/O glyphs to switches. UISwitch shows them automatically, but custom toggles built from Pressable or View can't. React Native apps can't currently detect this setting.

This adds AccessibilityInfo.isOnOffSwitchLabelsEnabled() and a onOffSwitchLabelsChanged event, following the existing isDarkerSystemColorsEnabled pattern. It reads UIAccessibilityIsOnOffSwitchLabelsEnabled() and observes UIAccessibilityOnOffSwitchLabelsDidChangeNotification. On Android, the method resolves to false.

Discussion: react-native-community/discussions-and-proposals#1026

Changelog:

[IOS] [ADDED] - AccessibilityInfo.isOnOffSwitchLabelsEnabled() and onOffSwitchLabelsChanged

Test Plan:

  • yarn jest packages/react-native/Libraries/Components/AccessibilityInfo: all tests pass
  • yarn flow-check: 0 errors
  • yarn lint: passes
  • yarn build-types --validate: API snapshot up to date
  • yarn test-generated-typescript and yarn test-typescript-legacy: pass
  • yarn format-check-cpp: passes
  • RNTester builds for the iOS simulator using Xcode 27.1

On an iPhone 18 Pro simulator running iOS 27.0: I flipped the setting in the simulator's Settings app with a throwaway XCUITest, not part of this PR, and read RNTester's Accessibility → "Check if the display options are enabled" row. RNTester stayed running the whole time, so the row could only update through the change event.

  • Before: "On/Off Labels is disabled."
  • Turned on: "On/Off Labels is enabled."
  • Turned off: "On/Off Labels is disabled."

Reads UIAccessibilityIsOnOffSwitchLabelsEnabled() and emits onOffSwitchLabelsChanged when it changes. Android resolves to false.

Adds Jest tests for the getter and the event wiring, and an RNTester row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Hi @camilopires!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 18, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 18, 2026

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant