A multiline text input that can automatically grow with its content.
You should have the chayns-components
package installed. If that is not the
case already, run
yarn add chayns-components
or
npm i chayns-components
After the chayns-components
package is installed, you can import the component
and use it with React:
import React from 'react'
import { TextArea } from 'chayns-components';
// ...
<TextArea {...} />
The TextArea
-component takes the following props:
Name | Type | Default | Required |
---|---|---|---|
style | { [key: string]: string | number } |
||
disabled | boolean |
false |
|
className | string |
||
placeholder | string |
||
required | boolean |
||
design | number |
TextArea.DEFAULT_DESIGN |
|
onChange | function |
||
onBlur | function |
||
defaultValue | string |
||
value | string |
||
onKeyUp | function |
||
onKeyDown | function |
||
autogrow | boolean |
||
reference | function |
||
stopPropagation | boolean |
false |
style?: { [key: string]: string | number }
A React style object that will be applied to the text area.
disabled?: boolean
Wether the component ignores any user interaction and is rendered with a disabled style.
className?: string
A classname string that will be applied to the <textarea>
-element.
placeholder?: string
A placeholder, that will be displayed if the text area is empty.
required?: boolean
Wether the text area is required for a form to complete. Renders the text area with an error style when its empty.
design?: number
The design of the input. Use either TextArea.DEFAULT_DESIGN
or
TextArea.BORDER_DESIGN
.
onChange?: function
A callback that is invoked when the value of the <textarea>
changes.
onBlur?: function
A callback that is invoked when the text area loses focus.
defaultValue?: string
The default value of the text area. Has no effect when the value
prop is used.
value?: string
The current text value of the area.
onKeyUp?: function
A callback that will be called when the keyup
-event is fired from the
<textarea>
-element.
onKeyDown?: function
A callback that will be called when the keydown
-event is fired from the
<textarea>
-element.
autogrow?: boolean
Wether the text area should automatically grow with its content.
reference?: function
A function that will be invoked with a reference to the <textarea>
-element or
null
.
stopPropagation?: boolean
Wether click events should be stopped from propagating to parent elements.