-
Notifications
You must be signed in to change notification settings - Fork 299
Open
Description
When using the CardForm component from @stripe/stripe-react-native, we are forced to provide a fixed height. This creates multiple issues:
- Platform inconsistency
- The required height is different on iOS and Android.
- Developers need to manually adjust styles per platform, which makes UI maintenance harder.
- Postal code field problem
- Some countries do not require a postal code, but the component still takes up space as if the field is present.
- Since the height is static, hiding the postal code creates layout issues (extra space or clipped UI).
- Lack of dynamic sizing
- Ideally, the component should be able to size itself dynamically based on which fields are shown.
- Currently, developers would need to maintain a full list of countries that don’t use postal codes, but this logic should already be handled internally by Stripe.
- API limitation
- The CardForm only exposes onBlur and onFocus events via ref.
- There’s no way to measure or listen to the internal layout changes in order to adapt the height dynamically.
Steps to reproduce the behaviour:
- Install and configure @stripe/stripe-react-native
- Add the CardForm component to a screen
- Run the app on iOS and note the required height for the form (height: iOS: 200, Android: 300).
- Run the same app on Android and observe that the form has a different intrinsic height.
- In the CardForm, select a country that does not require a postal code (e.g., [example country you tested: Ireland, Hong Kong, etc.])
- Notice that the postal code field disappears — but the height you defined remains static, causing either extra blank space or clipped UI.
Expected behaviour
- The CardForm should automatically adjust its height depending on platform and visible fields (e.g., postal code).
- Or, at least expose a method/event to measure its internal content height so developers can size it dynamically.
Smartphone (please complete the following information):
- Device: iPhone 16 Pro, Pixel 3a
- OS: iOS18.5, Android 14
- React Native version: 0.81.0
- @stripe/stripe-react-native version: 0.51.0
Metadata
Metadata
Assignees
Labels
No labels