The Textarea component helps create multi-line text inputs.
const Example = () => {
return <TextArea shadow={2} h={20} placeholder="Text Area Placeholder" w="200" _light={{
placeholderTextColor: 'trueGray.700'
}} _dark={{
bg: 'coolGray.800'
}} _hover={{
bg: 'coolGray.200'
}} />;
};
const Example = () => {
return <Box alignItems="center" w="100%">
<TextArea h={20} placeholder="Text Area Placeholder" w="75%" maxW="300" />
</Box>;
};
Invalid and Disabled TextArea
const Example = () => {
return <Box alignItems="center" w="100%">
<Stack space={2.5} w="75%" maxW="300">
<Box>
<Text mb="4" bold fontSize="lg">
Invalid TextArea
</Text>
<TextArea aria-label="t1" numberOfLines={4} placeholder="Invalid TextArea" isInvalid _dark={{
placeholderTextColor: "gray.300"
}} mb="5" />
<Divider />
</Box>
<Box>
<Text bold fontSize="lg" mb="4">
Disabled TextArea
</Text>
<TextArea aria-label="t1Disabled" placeholder="Disabled TextArea" isDisabled />
</Box>
</Stack>
</Box>;
};
Value Controlled TextArea
const Example = () => {
const [textAreaValue, setTextAreaValue] = useState("Value Controlled");
const demoValueControlledTextArea = e => {
setTextAreaValue(e.currentTarget.value);
};
return <Box alignItems="center" w="100%">
<TextArea value={textAreaValue} onChange={demoValueControlledTextArea} w="75%" maxW="300" />
</Box>;
};
TextArea implements
,
,
,
,
,
,
,
,
,
Maps to react-native TextInput's numberOfLines.
NativeBase ships with a default theme for each component. Check out the default theme of the textArea
.
Info:
We can easily extend the textArea component theme using extendTheme function as described in the documentation .