Skip to content

Commit d757a89

Browse files
feat: Add rows prop to TextInput component
1 parent f3def13 commit d757a89

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Libraries/Components/TextInput/TextInput.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,13 @@ type AndroidProps = $ReadOnly<{|
452452
*/
453453
returnKeyLabel?: ?string,
454454

455+
/**
456+
* Sets the number of rows for a `TextInput`. Use it with multiline set to
457+
* `true` to be able to fill the lines.
458+
* @platform android
459+
*/
460+
rows?: ?number,
461+
455462
/**
456463
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
457464
* Defaults to `true`.
@@ -1356,6 +1363,7 @@ function InternalTextInput(props: Props): React.Node {
13561363
disableFullscreenUI={props.disableFullscreenUI}
13571364
focusable={focusable}
13581365
mostRecentEventCount={mostRecentEventCount}
1366+
numberOfLines={props.rows ?? props.numberOfLines}
13591367
onBlur={_onBlur}
13601368
onChange={_onChange}
13611369
onFocus={_onFocus}

packages/rn-tester/js/examples/TextInput/TextInputExample.android.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,22 @@ exports.examples = ([
392392
<TextInput
393393
numberOfLines={2}
394394
multiline={true}
395-
placeholder="Two line input"
395+
placeholder="Two line input using numberOfLines prop"
396396
/>
397397
<TextInput
398398
numberOfLines={5}
399399
multiline={true}
400-
placeholder="Five line input"
400+
placeholder="Five line input using numberOfLines prop"
401+
/>
402+
<TextInput
403+
rows={2}
404+
multiline={true}
405+
placeholder="Two line input using rows prop"
406+
/>
407+
<TextInput
408+
rows={5}
409+
multiline={true}
410+
placeholder="Five line input using rows prop"
401411
/>
402412
</View>
403413
);

0 commit comments

Comments
 (0)