gluestack

gluestack Logogluestack

Textarea lines depending of input

emoplosion posted this in #support
Open in Discord
Avatar
emoplosionOP
Hi, im have a text area where i want to show minimum 1 line up to 4 lines depending on the content.
I only managed a workaround with line breaks but that doesn't make much sense in case there are longer sentences.
width of the textarea is responsive.

any ideas?

const lines = message?.split("\n").length || 1; <Textarea className="h-auto"> <TextareaInput className="font-sans text-300 leading-200" value={message} onChangeText={setMessage} onKeyPress={handleKeyPress} onEndEditing={handleSubmit} onSubmitEditing={handleSubmit} numberOfLines={lines > 4 ? 4 : lines} /> </Textarea>

1 Reply