Monster.Components.Form. Button

This CustomControl creates a button element with a variety of options.

Dependencies: the system uses functions of the monsterjs library

You can create this control either by specifying the HTML tagdirectly in the HTML or using Javascript via thedocument.createElement('monster-button');` method.

<monster-button></monster-button>

Or you can create this CustomControl directly in Javascript:

import {Button} from 'https://cdn.jsdelivr.net/npm/@schukai/[email protected]/dist/modules/button.js';
document.createElement('monster-button');

Constructor

new Button()

A simple button

Since
  • 1.5.0
Example
import {Button} from '@schukai/component-form/source/button.js';

const button = document.createElement('monster-button');
// set label
button.setOption('labels.button', 'Click')
// add action for click
button.setOption('actions.click', function (e) {
    console.log(e);
})
document.body.appendChild(button)

Members

defaults

This method is called internal and should not be called directly.

This method is called internal and should not be called directly.

To set the options via the html tag the attribute data-monster-options must be set. As value a JSON object with the desired values must be defined.

The JSON can be specified as a DataURI.

new Monster.Types.DataUrl(btoa(JSON.stringify({
       shadowMode: 'open',
       delegatesFocus: true,
       templates: {
           main: undefined
       }
   })),'application/json',true).toString()

The attribute data-monster-options-selector can be used to access a script tag that contains additional configuration.

As value a selector must be specified, which belongs to a script tag and contains the configuration as json.

<script id="id-for-this-config" type="application/json">
   {
       "config-key": "config-value"
   }
</script>

The individual configuration values can be found in the table.,'application/json',true).toString()

Properties
NameTypeDefaultDescription
clickEventTypeArrayclick,touch

List of event types to be observed for click the button

templatesObject

Template definitions

Properties
NameTypeDescription
mainstring

Main template

labelsObject

Labels

Properties
NameTypeDefaultDescription
buttonstring<slot></slot>

Button label

actionsObject

Callbacks

Properties
NameTypeDefaultDescription
clickstring"throw

Error" Callback when clicked

Methods

(static) getCSSStyleSheet() → {CSSStyleSheet}

Returns:
Type: 
CSSStyleSheet

(static) getTag() → {string}

Returns:
Type: 
string

assembleMethodSymbol() → {Monster.Components.Form.Button}