diff --git a/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm b/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm index 0f988c19d5c2..dbee656c95e6 100644 --- a/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +++ b/packages/react-native/Libraries/Text/TextInput/Singleline/RCTUITextField.mm @@ -33,7 +33,14 @@ @implementation RCTUITextFieldCell - (NSRect)titleRectForBounds:(NSRect)rect { - return UIEdgeInsetsInsetRect([super titleRectForBounds:rect], self.textContainerInset); + NSRect titleRect = UIEdgeInsetsInsetRect([super titleRectForBounds:rect], self.textContainerInset); + // Center the intrinsic text height within the padded control bounds. + CGFloat contentHeight = self.cellSize.height; + if (contentHeight < titleRect.size.height) { + titleRect.origin.y += (titleRect.size.height - contentHeight) / 2; + titleRect.size.height = contentHeight; + } + return titleRect; } - (void)editWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate event:(NSEvent *)event diff --git a/packages/react-native/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm b/packages/react-native/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm index 6f332dc1701c..c5aeaf80ac62 100644 --- a/packages/react-native/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm +++ b/packages/react-native/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.mm @@ -30,7 +30,14 @@ @implementation RCTUISecureTextFieldCell - (NSRect)titleRectForBounds:(NSRect)rect { - return UIEdgeInsetsInsetRect([super titleRectForBounds:rect], self.textContainerInset); + NSRect titleRect = UIEdgeInsetsInsetRect([super titleRectForBounds:rect], self.textContainerInset); + // Center the intrinsic text height within the padded control bounds. + CGFloat contentHeight = self.cellSize.height; + if (contentHeight < titleRect.size.height) { + titleRect.origin.y += (titleRect.size.height - contentHeight) / 2; + titleRect.size.height = contentHeight; + } + return titleRect; } - (void)editWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate event:(NSEvent *)event