Textarea
Textarea widgets are Input Fields that allow the user to enter multi-line string chains.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.textarea('comments', { label: 'Comments', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "textarea", "path": "comments", "label": "Comments" } ]}Use these props to customize your Textarea widget.
| prop | type | description |
|---|---|---|
autocomplete | string | 'on', 'off', or a space-separated list of W3C autofill tokens |
autoGrow | boolean | If true, the textarea will automatically expand its height as the user types |
counterMode | string | Mode for the character counter if validator.maxLength is set, possible values are remaining (default) or current |
hint | string | A description to display below the textarea |
minimumHeight | number | Minimum height of the textarea in pixels, defaults to 120 |
placeholder | string | A placeholder text to display when the textarea has no value |
Placeholder
Section titled “Placeholder”Use the property placeholder to add a placeholder.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.textarea('comments', { placeholder: 'Enter your comments here...', label: 'Comments', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "textarea", "path": "comments", "label": "Comments", "props": { "placeholder": "Enter your comments here..." } } ]}Use the property hint to add a description.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.textarea('comments', { hint: 'Please be descriptive.', label: 'Comments', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "textarea", "path": "comments", "label": "Comments", "props": { "hint": "Please be descriptive." } } ]}Character Counter
Section titled “Character Counter”Use the validator maxLength to limit the number of characters and display a character counter. You can change how it counts with counterMode (remaining or current).
The limit doesn’t block input. The user can type or paste past it, the counter shows the value is over the limit, and the input shows the maxLength error. The maxLength prop is deprecated: see Deprecated props.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.textarea('commentsRemaining', { counterMode: 'remaining', label: 'Comments', validator: { maxLength: 10, required: true, }, }), gui.inputs.textarea('commentsCurrent', { counterMode: 'current', label: 'Comments', validator: { maxLength: 10, required: true, }, }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "textarea", "path": "commentsRemaining", "label": "Comments", "props": { "counterMode": "remaining" }, "validator": { "type": "string", "maxLength": 10, "required": true } }, { "kind": "input", "type": "textarea", "path": "commentsCurrent", "label": "Comments", "props": { "counterMode": "current" }, "validator": { "type": "string", "maxLength": 10, "required": true } } ]}Auto Grow
Section titled “Auto Grow”Use the property autoGrow to allow the textarea to expand automatically based on content. You can combine it with minimumHeight to set its initial size.
import { gui } from '@golemui/gui-shared';
export default [ gui.inputs.textarea('comments', { autoGrow: true, minimumHeight: 50, label: 'Comments', }),];{ "$schema": "https://golemui.com/schemas/form.schema.json", "form": [ { "kind": "input", "type": "textarea", "path": "comments", "label": "Comments", "props": { "autoGrow": true, "minimumHeight": 50 } } ]}Deprecated props
Section titled “Deprecated props”This prop has no effect, and v3.0.0 removes it:
| Deprecated | Use instead |
|---|---|
maxLength | validator.maxLength, which controls the counter and the error |
Styling
Section titled “Styling”Textareas can be styled as explained in the Styling Guide.
CSS Variables
Section titled “CSS Variables”Following you will find a list with the CSS Variables and a quick description of what you will style.
| CSS Variable | Description |
|---|---|
--gui-font-sm | Counter text font size |
--gui-space-2 | Counter top margin |
--gui-intent-error | Counter error color when max length is exceeded |
--gui-space-gap--inner | Label gap and margin bottom |
--gui-padding | Input padding |
--gui-color-border | Input border color |
--gui-radius | Input radius |
--gui-color-bg | Input background color |
--gui-color-fg | Input text color |
--gui-color-primary | Input border color and outline on focus |
--gui-color-error | Input border color when invalid |
Anatomy
Section titled “Anatomy”This is the anatomy of the Textarea Widget in case you want to use your CSS styles.
<gui-textarea-input class="gui-textarea gui-field"> <gui-textarea class="gui-field"> <label class="gui-label" for="fieldUid" id="fieldUid_label"> <span class="gui-label__text">Label</span> <div class="gui-widget-hint" id="fieldUid_hint" aria-hidden="true">Hint</div> </label>
<div class="gui-widget"> <textarea class="gui-widget-input" id="fieldUid" placeholder="Custom placeholder" aria-describedby="fieldUid_hint" style="height: 120px; min-height: 120px" ></textarea> </div>
<div class="gui-textarea--validation"> <div> <div class="gui-validator gui-validator--empty" id="fieldUid_errors" role="alert"></div> </div> <div class="gui-textarea--counter"> <span>0</span> <span>/ 100</span> </div> </div> </gui-textarea></gui-textarea-input>