Class: StatefulButton

UI.Components. StatefulButton


new StatefulButton()

Creates a new instance of StatefulButton.
Properties:
Name Type Description
properties Object An object that contains the properties of the StatefulButton.
Properties
Name Type Argument Description
states Object An object that contains the states of the button.
initialState string The initial state of the button.
mount function The function that is called when the button is mounted.
unmount function <optional>
The function that is called when the button is unmounted.
dataElement string <optional>
The data element of the button.
title string <optional>
The title of the button which appears in a tooltip.
hidden boolean <optional>
Whether the button is hidden or not.
Example
const myButton = new instance.UI.Components.StatefulButton({
  initialState: 'SinglePage',
  states: {
    SinglePage: {
      img: 'icon-header-page-manipulation-page-layout-single-page-line',
      onClick: (update) => {
        update('DoublePage');
      },
      title: 'Single Page',
    },
    DoublePage: {
      img: 'icon-header-page-manipulation-page-layout-double-page-line',
      onClick: (update) => {
        update('SinglePage');
      },
      title: 'Double Page',
    },
  },
  mount: () => {},
});

Extends