UI Switch - phreaknation/phaserwebcomponents GitHub Wiki

On and off toggle for a boolean value.

new this.game.PhaserWebComponents.components.UI.Switch({
  game: this.game,
  // attach to an HTML component. Will replace what ever selector you have
  target: htmlNode.querySelector('switch[data-replace="asdf"]'),
  // attach to a phaser object.
  // owner: PhaserObject,
  events: {
    switch: (name, data) => {
      // do stuff
      console.log('Event: ', name, data);
    }
  },
  options: {}
})