Textarea

Forms

A multi-line text input that grows automatically with its content up to a configurable maximum height.

GitHub

Installation

bash
1
npx native-mate add textarea

Examples

#FAFAFA
Radius100%

Usage

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
import { Textarea } from '~/components/ui/textarea'
import { useState } from 'react'

const [bio, setBio] = useState('')

<Textarea
  label="Bio"
  placeholder="Tell us about yourself…"
  value={bio}
  onChangeText={setBio}
  hint="Up to 300 characters"
  maxRows={6}
/>

Props

PropTypeDefaultDescription
labelstringLabel rendered above the textarea.
errorstringError message rendered below. Turns the border red.
hintstringHelper text shown below the textarea.
minRowsnumber3Minimum number of visible rows.
maxRowsnumber8Maximum rows before the textarea scrolls internally.
...TextInputPropsTextInputPropsAll standard RN TextInput props are forwarded.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { useState } from 'react'
import { Textarea } from '~/components/ui/textarea'
import { Button } from '~/components/ui/button'
import { View } from 'react-native'

export function TextareaExample() {
  const [message, setMessage] = useState('')

  return (
    <View style={{ gap: 12, padding: 16 }}>
      <Textarea
        label="Message"
        placeholder="Write your message here…"
        value={message}
        onChangeText={setMessage}
        minRows={4}
        maxRows={10}
        hint={`${message.length} / 500`}
      />
      <Button disabled={message.trim().length === 0}>Send</Button>
    </View>
  )
}