Skip to content

feat(ios): add backgroundColor prop to top bar buttons#8301

Open
IsaacIsrael wants to merge 3 commits into
wix:masterfrom
IsaacIsrael:feat/button-background-color
Open

feat(ios): add backgroundColor prop to top bar buttons#8301
IsaacIsrael wants to merge 3 commits into
wix:masterfrom
IsaacIsrael:feat/button-background-color

Conversation

@IsaacIsrael
Copy link
Copy Markdown
Contributor

Problem

On iOS 26, React Native Navigation exposes no way to set a solid background color on the circular Liquid Glass platter that UIKit draws behind each bar button item. Apps may want to highlight specific buttons (e.g., a primary action) with a colored background.

Solution

Add a new backgroundColor property to OptionsTopBarButton (TypeScript) and RNNButtonOptions (native) that sets a solid UIColor on the platter container view behind React component bar buttons.

Native changes

  • RNNButtonOptions.h/mm — parse, copy, and merge backgroundColor (Color)
  • RNNButtonBuilder.mm — pass [button.backgroundColor withDefault:nil] to RNNReactButtonView.buttonBackgroundColor
  • RNNReactButtonView.h — new buttonBackgroundColor property
  • RNNReactButtonView.mmsyncButtonBackground method targets the _UINavigationBarPlatterSubviewContainerView (self.superview.superview.superview) and applies:
    • backgroundColor (or clearColor when nil — prevents color leaking between buttons)
    • cornerRadius = bounds.height / 2 to maintain the circular shape
    • clipsToBounds = YES
    • Called from both didMoveToWindow (early, prevents flash on push) and layoutSubviews (handles re-layouts)

TypeScript changes

  • Options.ts — add backgroundColor?: Color to OptionsTopBarButton

Depends on: #8300

Usage

rightButtons: [{
  id: 'save',
  component: { name: 'SaveButton' },
  backgroundColor: 'yellow',  // fills the circular platter
}]

Test plan

  • Set backgroundColor: 'yellow' on a top bar button — verify the entire circular platter is filled
  • Navigate to a screen without backgroundColor — verify no color leaks to other buttons
  • Navigate back to the colored button — verify it re-applies without visible flash or square shape
  • Test with multiple colors (green, red, blue)
  • Verify buttons without backgroundColor remain unaffected

Made with Cursor

IsaacIsrael and others added 3 commits May 13, 2026 19:04
On iOS 26 the Liquid Glass navigation bar wraps custom-view bar button
items in several internal layout containers.  Without explicit size
constraints the wrapper views can collapse to zero height after a
pop → tab-switch → tab-switch → push cycle, making the React button
invisible.

- Guard all new logic behind @available(iOS 26.0, *) AND a runtime
  check for UIDesignRequiresCompatibility (compatibility mode disables
  Liquid Glass and uses the legacy view hierarchy)
- Set translatesAutoresizingMaskIntoConstraints = NO
- Add width/height constraints at UILayoutPriorityDefaultHigh
- Update constraints in didMountComponentsWithRootTag: after sizeToFit

Co-authored-by: Cursor <cursoragent@cursor.com>
On iOS 26 the internal _UITAMICAdaptorView wrapper is wider than the
React button content and UIKit pins the custom view to the leading edge.

Apply a one-time horizontal CGAffineTransform in layoutSubviews to
center the view. Guarded by @available(iOS 26.0, *) and
UIDesignRequiresCompatibility check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add a new `backgroundColor` option to `OptionsTopBarButton` that sets a
solid color on the iOS 26 Liquid Glass circular platter behind React
component bar buttons.

All logic is guarded by @available(iOS 26.0, *) and a runtime check for
UIDesignRequiresCompatibility — when compatibility mode is enabled the
prop is ignored and the button renders as before.

Co-authored-by: Cursor <cursoragent@cursor.com>
@IsaacIsrael IsaacIsrael force-pushed the feat/button-background-color branch from 982ab4a to 70207b6 Compare May 13, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant