Skip to content

CardForm requires static height — different on iOS/Android and affected by postal code field #2075

@restarajat

Description

@restarajat

When using the CardForm component from @stripe/stripe-react-native, we are forced to provide a fixed height. This creates multiple issues:

  1. Platform inconsistency
  • The required height is different on iOS and Android.
  • Developers need to manually adjust styles per platform, which makes UI maintenance harder.
  1. 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).
  1. 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.
  1. 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:

  1. Install and configure @stripe/stripe-react-native
  2. Add the CardForm component to a screen
  3. Run the app on iOS and note the required height for the form (height: iOS: 200, Android: 300).
  4. Run the same app on Android and observe that the form has a different intrinsic height.
  5. In the CardForm, select a country that does not require a postal code (e.g., [example country you tested: Ireland, Hong Kong, etc.])
  6. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions