[ui][ios] - Match Button API with SwiftUI#41617
Merged
intergalacticspacehighway merged 13 commits intomainfrom Dec 16, 2025
Merged
[ui][ios] - Match Button API with SwiftUI#41617intergalacticspacehighway merged 13 commits intomainfrom
intergalacticspacehighway merged 13 commits intomainfrom
Conversation
Contributor
|
Subscribed to pull request
Generated by CodeMention |
Collaborator
|
The Pull Request introduced fingerprint changes against the base commit: 98d06cb Fingerprint diff[
{
"op": "changed",
"beforeSource": {
"type": "dir",
"filePath": "../../packages/expo-ui/ios",
"reasons": [
"expoAutolinkingIos"
],
"hash": "cd35c3281d0996f9152955f937c9295467960df5"
},
"afterSource": {
"type": "dir",
"filePath": "../../packages/expo-ui/ios",
"reasons": [
"expoAutolinkingIos"
],
"hash": "0a23ff7b0669e6023fee45c2ebd6d067775908b2"
}
}
]Generated by PR labeler 🤖 |
| You can pass custom components as `children` for more complex button label content. | ||
|
|
||
| ```tsx CustomContentExample.tsx | ||
| import { Host, Button, VStack, Image, Text } from '@expo/ui/swift-ui'; |
Member
There was a problem hiding this comment.
Suggested change
| import { Host, Button, VStack, Image, Text } from '@expo/ui/swift-ui'; | |
| import { Host, Button, VStack } from '@expo/ui/swift-ui'; | |
| import { Image } from 'expo-image'; | |
| import { Text } from 'react-native'; |
I suppose we don't have Image and Text components in @expo/ui/swift-ui?
Contributor
Author
There was a problem hiding this comment.
yeah we do! Image supports systemImage and we also have Text. But they do not have documentation yet 😅
Member
There was a problem hiding this comment.
Thanks for the clarification!
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
amandeepmittal
approved these changes
Dec 15, 2025
Kudo
approved these changes
Dec 15, 2025
| func body(content: Content) -> some View { | ||
| content.controlSize(size.toNativeControlSize()) | ||
| } | ||
| } No newline at end of file |
aleqsio
pushed a commit
that referenced
this pull request
Dec 22, 2025
# Why Matches Button's API with SwiftUI and adds missing modifiers. This is a breaking change but refactoring the component to new changes should be easy. This simplifies a lot of conditional code on native side. It will be easier to add features/debug. <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> # How Updated the API, examples and docs. ### Breaking changes - Replaced string support in `children` prop with a `label` prop. The reason for this is that when `children` is used for string it requires call to special method `getTextFromChildren`, which tries to iterate the children and checks if it's a string. This always felt a bit awkward. Introducing `label` prop removes this requirement and makes our API match with the [SwiftUI API](https://developer.apple.com/documentation/swiftui/button/init(_:action:)) since SwiftUI's Button accepts label argument in the constructor for string labels. - Removed support for icon only buttons. SwiftUI Button's documentation states that one should pass label and use `labelStyle` with `iconOnly` for icon buttons. Passing label is required in SwiftUI's API as it is a required for accessibility/screen readers. So we follow the same approach with our API. Also, added documentation to create icon only buttons. - Removed support for `color`, `controlSize` and `variant` props. Added modifiers for each of these. <!-- How did you build this feature or fix this bug and why? --> # Test Plan Tested all the Button usage screens by updating to the new changes. <!-- Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction. --> # Checklist <!-- Please check the appropriate items below if they apply to your diff. --> - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [x] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [x] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) --------- Co-authored-by: Aman Mittal <amandeepmittal@live.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Matches Button's API with SwiftUI and adds missing modifiers. This is a breaking change but refactoring the component to new changes should be easy. This simplifies a lot of conditional code on native side. It will be easier to add features/debug.
How
Updated the API, examples and docs.
Breaking changes
childrenprop with alabelprop. The reason for this is that whenchildrenis used for string it requires call to special methodgetTextFromChildren, which tries to iterate the children and checks if it's a string. This always felt a bit awkward. Introducinglabelprop removes this requirement and makes our API match with the SwiftUI API since SwiftUI's Button accepts label argument in the constructor for string labels.labelStylewithiconOnlyfor icon buttons. Passing label is required in SwiftUI's API as it is a required for accessibility/screen readers. So we follow the same approach with our API. Also, added documentation to create icon only buttons.color,controlSizeandvariantprops. Added modifiers for each of these.Test Plan
Tested all the Button usage screens by updating to the new changes.
Checklist
changelog.mdentry and rebuilt the package sources according to this short guidenpx expo prebuild& EAS Build (eg: updated a module plugin).