File tree 1 file changed +13
-0
lines changed
packages/react-native-web/src/exports/Text
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ const Text: React.AbstractComponent<TextProps, HTMLElement & PlatformMethods> =
121
121
const componentDirection = props . dir || langDirection ;
122
122
const writingDirection = componentDirection || contextDirection ;
123
123
124
+ const capitalizeText = ( text ) => {
125
+ return text . toLowerCase ( ) . replace ( / \b \w / g, ( char ) => char . toUpperCase ( ) ) ;
126
+ } ;
127
+
124
128
const supportedProps = pickProps ( rest ) ;
125
129
supportedProps . dir = componentDirection ;
126
130
// 'auto' by default allows browsers to infer writing direction (root elements only)
@@ -145,6 +149,15 @@ const Text: React.AbstractComponent<TextProps, HTMLElement & PlatformMethods> =
145
149
onPress && styles . pressable
146
150
] ;
147
151
152
+ if ( props . style && props . style . textTransform === 'capitalize' ) {
153
+ supportedProps . children = React . Children . map ( props . children , child => {
154
+ if ( typeof child === 'string' ) {
155
+ return capitalizeText ( child ) ;
156
+ }
157
+ return child ;
158
+ } ) ;
159
+ }
160
+
148
161
if ( props . href != null ) {
149
162
component = 'a' ;
150
163
if ( hrefAttrs != null ) {
You can’t perform that action at this time.
0 commit comments