Textarea
Examples
By default, Textarea
is not resizeable. However, you can use overrides
as in the example above to supply minimum and maximum dimensions for the component. This will allow users to resize the Textarea
within the boundaries you define.
AutoFocus
Textarea
accepts an autoFocus
prop. For information on its behaviour, check Input's autoFocus example.
As with many of our components, there is also an uncontrolled version, StatefulTextarea
, which manages its own state.
API
Textarea props
Name | Type | Default | Description |
---|---|---|---|
animate | boolean | false | Enable animation for certain parts of input. e.g. shows animated border on hover for ai intent |
aria-describedby | string | Sets aria-describedby attribute. | |
aria-label | string | Sets aria-label attribute. | |
aria-labelledby | string | Sets aria-labelledby attribute. | |
autoComplete | string | Determines if browser should provide value suggestions. | |
autoFocus | string | Takes "start" | "end" | number | boolean values and sets the position of the cursor on mount. | |
autoSize | boolean | false | If true, textarea resizes as per the value entered automatically. |
className | string | className to modify style of Input container | |
clearable | boolean | false | If true, adds a clear value icon button to the end of the input container. |
debounceInterval | number | debouncedOnChange function will be called after onChange stops being called for this duration in milliseconds. | |
debouncedOnChange | function | Debounced handler of onChange. Specify interval with `debounceInterval` prop. | |
disabled | boolean | false | Renders component in disabled state. |
draggable | boolean | false | Set it to true if the input is rendered in a dnd component. When true, onDragStart's default behaviour will be prevented. |
id | string | Id attribute value to be added to the input element and as a label's for attribute value. | |
inputMode | string | A hint as to the type of data that might be entered by the user while editing the element or its contents. | |
inputRef | ref | A ref to access an input element. | |
intent | 'default' | 'success' | 'warning' | 'error' | 'ai' | Defines the intent of the Input. | |
max | string | max value when used as input type=number | |
maxCharLimit | number | Maximum character needed | |
min | string | min value when used as input type=number | |
name | string | Name attribute. | |
onBlur | function | Called the onBlur event triggers. | |
onChange | function | Called when input value is changed. | |
onFocus | function | Called the onFocus event triggers. | |
onKeyDown | function | Called the onKeyDown event triggers. | |
onKeyPress | function | Called the onKeyPress event triggers. | |
onKeyUp | function | Called the onKeyUp event triggers. | |
overrides | custom | Lets you customize all aspects of the component. | |
pattern | string | A regex that is used to validate the value of the input on form submission. | |
placeholder | string | Input's placeholder. | |
required | boolean | false | Renders component in required state. |
rows | number | Sets the height of textarea. Defaults to 3 (if autoSize is false), 1 (if autoSize is true) | |
size | 'xs' | 'sm' | 'md' | Input's size. SPACIOUS | COMFORTABLE -> md, COMPACT -> xxxs, DEFAULT -> md | |
style | string | className to modify style of Input container | |
value | string | Input value attribute. | |
variant | 'default' | 'line' | Input's variant - default, line |
You can check the implementation of the component for more details.
Textarea exports
You can import this module like so:
import {STATE_CHANGE_TYPE} from 'spaceweb/textarea'
It exports the following components or utility functions:
- STATE_CHANGE_TYPE
- StatefulTextarea
- StyledTextarea
- StyledTextareaContainer
- Textarea