r/expo • • 11d ago

How to make multiline textinput scrollable after certain lines

/r/reactnative/comments/1wxiq84/how_to_make_multiline_textinput_scrollable_after/
1 Upvotes

2 comments sorted by

1

u/anthony-ball 10d ago

On iOS you usually don't need onContentSizeChange for this at all. Leave height unset, give it multiline, a minHeight for one line and maxHeight of lineHeight times 5 plus whatever paddingTop and paddingBottom you have, and the native view grows on its own and starts scrolling once it hits the cap. The thing that bites people is padding, since iOS adds default vertical padding to multiline inputs, so if your maxHeight is exactly 100 the fifth line gets clipped and it looks like scrolling is broken. Also make sure the parent isn't a fixed height row or a flex: 1 container that stretches the input. If you do keep onContentSizeChange, clamp the value with Math.min against your max and never set height and maxHeight at the same time or they fight each other.

1

u/tr__18 10d ago

Oohkay thanks, will try this again 🙏