Textarea

new Textarea(options) → {Class}

A textarea component to use wherever textarea form fields are needed.

Parameters:
NameTypeDescription
optionsobject

The options for the component.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes for the textarea.

customClassesArray

Any custom classes for the textarea.

helpTextstring

Optional helper text.

idstring

Optional id. Auto generated if not passed.

labelstring

Label for the textarea.

labelCustomAttributesobject

Any custom attributes for the label.

labelCustomClassesArray

Any custom classes for the label.

labelVisibleboolean

If the label should be visible. Defaults to true.

placeholderstring

Optional placeholder text.

renderedstring

Is the component already rendered in the dom, eg by php?

renderOnInitstring

Render the component on init of the class?

spacingstring

Spacing for the component.

targetstring

The target to render to. Any valid css selector string.

targetPositionstring

The insert position for the component relative to the target.

themestring

Theme for the component, primary or cosmos.

valuestring

Optional initial value for the textarea.

wrapperCustomAttributesobject

Any custom attributes for the textarea wrapper.

wrapperCustomClassesArray

Any custom classes for the textarea wrapper.

wrapperTagNamestring

Tag to use for the textarea wrapper. Defaults to 'div',

Since
  • 1.1.18
Returns:

The class instance.

Type: 
Class
Example
import Textarea from '@gravityforms/components/html/admin/elements/Textarea';

function Example() {
     const textareaInstance = new Textarea( {
         id: 'example-textarea',
         renderOnInit: false,
         target: '#example-target',
         targetPosition: 'beforeend',
         theme: 'cosmos',
     } );

     // Some time later we can render it. This is only done if we set renderOnInit to false.
     // If true it will render on initialization.
     textareaInstance.init();
}

Methods

(static) init() → {void}

Initialize the component.

Since
  • 1.1.16
Returns:
Type: 
void

(static) render() → {void}

Renders the component into the dom.

Since
  • 1.1.16
Returns:
Type: 
void

(static) textareaTemplate(options) → {string}

The markup for a textarea.

Parameters:
NameTypeDescription
optionsobject

The options for the component template.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes for the textarea.

customClassesArray

Any custom classes for the textarea.

helpTextstring

Optional helper text.

idstring

Optional id. Auto generated if not passed.

labelstring

Label for the textarea.

labelCustomAttributesobject

Any custom attributes for the label.

labelCustomClassesArray

Any custom classes for the label.

labelVisibleboolean

If the label should be visible. Defaults to true.

disabledboolean

If the textarea should be disabled. Defaults to false.

placeholderstring

Optional placeholder text.

spacingstring | number | Array | object

The spacing for the component, string, number, object or array.

themestring

Theme for the toggle, primary or cosmos.

valuestring

Optional initial value for the textarea.

wrapperCustomAttributesobject

Any custom attributes for the textarea wrapper.

wrapperCustomClassesArray

Any custom classes for the textarea wrapper.

wrapperTagNamestring

Tag to use for the textarea wrapper. Defaults to 'div',

Since
  • 1.1.18
Requires:
  • module:labelTemplate
  • module:helpTextTemplate
Returns:
Type: 
string
Example
import { textareaTemplate } from '@gravityforms/components/html/admin/elements/Textarea';

function Example() {
     const textareaHTML = textareaTemplate( options );
     document.body.insertAdjacentHTML( 'beforeend', textareaHTML );
}