Textarea
Easily input and customize larger amounts of text with multi-line functionality.
Installation
API Reference
This is an illustration of Textarea component.
size
isReadOnly
isInvalid
isDisabled
<Textareasize="md"isReadOnly={false}isInvalid={false}isDisabled={false}className="w-64"><TextareaInput placeholder="Your text goes here..." /></Textarea>
Installation
CLI
Manual
Run the following command:
npx gluestack-ui add textarea
API Reference
To use this component in your project, include the following import statement in your file.
import { Textarea } from "@/components/ui/textarea"
export default () => (<Textarea><TextareaInput /></Textarea>)
Component Props
This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.
Textarea
It inherits all the properties of React Native's View component.
Prop | Type | Default | Description |
---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Changes the size of the Input Text |
isInvalid | bool | false | When true, the input displays an error state. |
isDisabled | bool | false | When true, the input is disabled and cannot be edited. |
isHovered | bool | false | When true, the input displays a hover state. |
isFocused | bool | false | When true, the input displays a focus state. |
isRequired | bool | false | If true, sets aria-required="true" on the input. |
isReadOnly | bool | false | If true, the input value cannot be edited. |
Descendants Styling Props
Props to style child components.
Sx Prop | Description |
---|---|
_input | Prop to style TextareaInput Component |
TextareaInput
Contains all TextInput related layout style props and actions.
It inherits all the properties of React Native's TextInput component.
Accessibility
We have outlined the various features that ensure the Textarea component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards.
Keyboard
- setting the aria-label and aria-hint
Screen Reader
- VoiceOver: accessible and aria-label props to describe the input's purpose
- aria-traits and aria-hint for the various states of the input, such as "double tap to edit"
Props
Textarea component is created using TextInput component from react-native. It extends all the props supported by React Native Text Input and the props mentioned below.
Textarea
Name | Value | Default |
---|---|---|
size | xl | lg | md | sm | md |
Data Attributes Table
Component receives states as props as boolean values, which are applied as data-* attributes. These attributes are then used to style the component via classNames, enabling state-based styling.
State | Data Attribute | Values |
---|---|---|
hover | data-hover | true | false |
focus | data-focus | true | false |
disabled | data-disabled | true | false |
invalid | data-invalid | true | false |
Examples
The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.
FormControl
The Textarea Component can be incorporated within the FormControl.
<FormControl size="sm" className="max-w-[200px] w-full"><FormControlLabel><FormControlLabelText>Write with me</FormControlLabelText></FormControlLabel><Textarea><TextareaInput placeholder="Once upon a time..." /></Textarea><FormControlHelper><FormControlHelperText>Start your story</FormControlHelperText></FormControlHelper></FormControl>