Link

A link component .

Parameters:
NameTypeDescription
optionsobject

The options for the component.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes for the component.

customClassesArray

An array of additional classes for the component.

hrefstring

Href for the link.

idstring

Id for the component, auto generated if not passed.

labelstring

Text label for the link.

linkTargetstring

Target for the link, eg _blank.

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.

Since
  • 1.1.16
Returns:

The class instance.

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

function Example() {
     const linkInstance = new Link( {
         id: 'example-link',
         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.
     linkInstance.init();
}

Methods

(static) init() → {void}

Initialize the component.

Since
  • 1.1.16
Returns:
Type: 
void

(static) linkTemplate(options) → {string}

Generates the markup for a link in the admin.

Parameters:
NameTypeDescription
optionsobject

The options for the component template.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes.

customClassesArray

An array of additional classes for the toggle.

hrefstring

Href for the link.

idstring

Id for the link, auto generated if not passed.

labelstring

Text label for the link.

linkTargetstring

Target for the link, eg _blank.

spacingstring | number | Array | object

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

themestring

Theme for the toggle, primary or cosmos.

Since
  • 1.1.16
Returns:
Type: 
string
Example
import { linkTemplate } from '@gravityforms/components/html/admin/elements/Link';

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

(static) render() → {void}

Renders the component into the dom.

Since
  • 1.1.16
Returns:
Type: 
void