Textarea
Text area.
Props
- name (string):
nameHTML attribute to set to the element. - [OPTIONAL] id (string):
idHTML attribute to set to the element. - [OPTIONAL] label (string): Element label. Supports light markdown.
- [OPTIONAL] helper (string): Element helper. Supports light markdown.
- [OPTIONAL] placeholder (string):
placeholderHTML attribute to set to the element. - [OPTIONAL] modifiers (string): List of modifiers to apply to the element. Defaults to
"". - [OPTIONAL] maxLength (number):
maxlengthHTML attribute to set to the element. - [OPTIONAL] cols (number):
colsHTML attribute to set to the element. - [OPTIONAL] rows (number):
rowsHTML attribute to set to the element. - [OPTIONAL] readonly (boolean):
readonlyHTML attribute to set to the element. Defaults tofalse. - [OPTIONAL] autoresize (boolean): Wether to automatically resize textarea height when user puts line-breaks. Defaults to
false. - [OPTIONAL] autocomplete ("on" | "off"):
autocompleteHTML attribute to set to the element. Defaults tooff. - [OPTIONAL] value (string | number): Textarea value. Updating this prop with a new value will replace the current value by the one passed. Defaults to
"". - [OPTIONAL] debounceTimeout (number): Number of milliseconds to wait before triggering the
changeevent. If user changes the textarea value during that time, the timeout is reset. This is especially useful to limit the number of triggers, if you want to use this component as an autocomplete performing HTTP requests on user inputs, for instance. Defaults to50. - [OPTIONAL] disabled (boolean): When element is disabled, a special
disabledmodifier is automatically added, and all its user interactions are disabled. Defaults tofalse.
Events
- change (newValue: string, event: InputEvent) => void: Triggered whenever textarea value is modified.
- focus (currentValue: string, event: FocusEvent) => void: Triggered whenever the textarea is focused.
- blur (currentValue: string, event: FocusEvent) => void: Triggered whenever the textarea is blurred.
- paste (event: ClipboardEvent) => void: Triggered whenever user pastes content in the textarea.
- keyDown (event: KeyboardEvent) => void: Triggered whenever user presses a key in the textarea.
Behavior
- While user is typing, updating the
valueprop won't have any effect within thedebounceTimeoutduration. This ensures that value is not directly updated while user is typing, which would lead to a bad UX.
Syntax - with label and helper
- React
- Vue
- Svelte
- HTML
<UITextarea
name="test"
label="Label"
helper="Helper"
/>
<UITextarea
name="test"
label="Label"
helper="Helper"
/>
<UITextarea
name="test"
label="Label"
helper="Helper"
/>
<div class="ui-textarea">
<label
class="ui-textarea__label"
for="z8a8d7a5zad4"
>
Label
</label>
<div class="ui-textarea__wrapper">
<textarea
autocomplete="on"
class="ui-textarea__wrapper__field"
id="z8a8d7a5zad4"
name="test"
tabindex="0"
/>
</div>
<span class="ui-textarea__helper">
Helper
</span>
</div>
Syntax - disabled
- React
- Vue
- Svelte
- HTML
<UITextarea
name="test"
disabled
/>
<UITextarea
name="test"
disabled
/>
<UITextarea
name="test"
disabled
/>
<div class="ui-textarea ui-textarea--disabled">
<div class="ui-textarea__wrapper">
<textarea
class="ui-textarea__wrapper__field"
id="z8a8d7a5zad4"
name="test"
disabled=""
tabindex="-1"
/>
</div>
</div>
Syntax - readonly
- React
- Vue
- Svelte
- HTML
<UITextarea
name="test"
readonly
/>
<UITextarea
name="test"
readonly
/>
<UITextarea
name="test"
readonly
/>
<div class="ui-textarea">
<div class="ui-textarea__wrapper">
<input
class="ui-textarea__wrapper__field"
id="z8a8d7a5zad4"
name="test"
readonly=""
tabindex="0"
/>
</div>
</div>
Syntax - disabled
- React
- Vue
- Svelte
- HTML
<UITextarea
name="test"
disabled
/>
<UITextarea
name="test"
disabled
/>
<UITextarea
name="test"
disabled
/>
<div class="ui-textarea ui-textarea--disabled">
<div class="ui-textarea__wrapper">
<textarea
class="ui-textarea__wrapper__field"
id="z8a8d7a5zad4"
name="test"
disabled=""
tabindex="-1"
/>
</div>
</div>