react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

Add support for iOS 26 subtitle in native stack

Open fbeccaceci opened this issue 4 months ago • 5 comments

Description

This PR adds support for new properties introduced in iOS 26 as subtitle and largeSubtitle

Changes

  • Update RNSScreenStackHeaderConfig.h and RNSScreenStackHeaderConfig.mm to support new iOS 26 subtitle

Screenshots / GIFs

Screenshot 2025-09-05 alle 16 20 16 Screenshot 2025-09-05 alle 16 20 07

Test code and steps to reproduce

<Stack.Screen
      name="root"
      component={MainScreen}
      options={{
        headerLargeTitle: true,
        headerTransparent: true,
        title: 'Future of Mobile Dev',
        // @ts-expect-error
        subtitle: '09/05/2025 • 5 min read',
      }}
    />

Inside of TestSubtitle.tsx you can pass to the screen option these new options:

 subtitle?: string;
  /**
   * Allows for setting text color of the subtitle.
   */
  subtitleColor?: ColorValue;
  /**
   * Customize font family to be used for the subtitle.
   */
  subtitleFontFamily?: string;
  /**
   * Customize the size of the font to be used for the subtitle.
   */
  subtitleFontSize?: number;
  /**
   * Customize the weight of the font to be used for the subtitle.
   */
  subtitleFontWeight?: string;
  /**
   * String that can be displayed in the header below title.
   */
  largeSubtitle?: string;
  /**
   * Allows for setting text color of the subtitle.
   */
  largeSubtitleColor?: ColorValue;
  /**
   * Customize font family to be used for the subtitle.
   */
  largeSubtitleFontFamily?: string;
  /**
   * Customize the size of the font to be used for the subtitle.
   */
  largeSubtitleFontSize?: number;
  /**
   * Customize the weight of the font to be used for the subtitle.
   */
  largeSubtitleFontWeight?: string;

Keep in mind that TypeScript will throw an error since the scope of this PR is just react-native-screens not react-navigation and the modification in the react-navigation submodule just aim to pass through the new props.

Checklist

  • [x] Included code example that can be used to test this change
  • [x] Updated TS types
  • [ ] Updated documentation:
    • [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
    • [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
    • [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
    • [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
  • [ ] Ensured that CI passes

fbeccaceci avatar Sep 05 '25 14:09 fbeccaceci

Nice work! After this is landed I think next step should be to add support for subtitleView: ReactElement and largeSubtitleView: ReactElement.

More info: https://developer.apple.com/documentation/uikit/uinavigationitem/subtitleview?changes=_7&language=objc https://developer.apple.com/documentation/uikit/uinavigationitem/largesubtitleview?changes=_7&language=objc

johankasperi avatar Sep 08 '25 20:09 johankasperi

You can also modify largeTitle independently from title, similar to how largeSubtitle overrides subtitle (docs). If we want to also add support for largeTitle, I'm thinking how are we going to name this property because currently largeTitle/headerLargeTitle is a boolean property. We can add some kind of suffix like headerLargeTitleText but if all other props would be just largeSubtitle, subtitle, title without the suffix, this would be a little bit inconsistent.

kligarski avatar Sep 11 '25 10:09 kligarski

I reasoned on this as well while working on this PR. My personal opinion is that the most correct solution would be to turn largeTitle to string and make it work as it is supposed to, but this would break compatibility with older versions.

A solution to don't break the api could be to make largeTitle boolean | string and when true is passed as value just set it to the same value of title, allowing for a string to be passed if the user want's to have another value

fbeccaceci avatar Sep 11 '25 10:09 fbeccaceci

Do you have any update on the expected arrival time?

aledebla03 avatar Sep 28 '25 09:09 aledebla03

Hi @kkafar will you review this PR?

ajanuar avatar Nov 03 '25 12:11 ajanuar