Skip to content
Changelog

Bring in StreamElements and Streamlabs widgets

Import a StreamElements or Streamlabs custom widget, or a .lwidget package, and run it in Lightair with your chat and events, its settings in the Inspector.

In short

  • Save the widget's HTML, CSS, JavaScript and fields as files in one folder.
  • In the Hierarchy, click +, choose Widgets › Import a widget, and pick the folder or a .lwidget file.
  • Lightair feeds it your chat and events in the form StreamElements or Streamlabs would, and its fields become settings in the Inspector.

In the appHierarchy › Add object › Widgets › Import a widget

A custom widget you made for StreamElements or Streamlabs, or one you got from someone else, runs in Lightair from its own files. It receives the same kinds of events it did before: chat messages, follows, subs, donations, cheers and raids, from every platform you’ve connected in Lightair.

A custom widget is four pieces of code: HTML, CSS, JavaScript and its fields (the settings, as JSON). Put each in a file in one folder of its own:

Piece File name
HTML ends in .html or .htm, for example widget.html
CSS ends in .css, for example widget.css
JavaScript ends in .js, for example widget.js
Fields a .json file with “field” in its name, for example fields.json

In StreamElements’ or Streamlabs’ custom widget editor, copy each tab into its file. Only the HTML or the JavaScript is required; leave out the pieces the widget doesn’t have.

A .lwidget file is the same four files in one zip package. Lightair reads .zip files of them too.

  1. Select the scene, then click + (Add object) at the top of the Hierarchy panel.
  2. Choose Widgets, then Import a widget under Your own.
  3. Pick the widget’s folder, or its .lwidget file.

The widget is added to the scene. If Lightair can’t find the code, it says Couldn’t import that widget and why: for example, there’s no HTML or JS file in the folder.

You can also install a .lwidget as a package: drop it on the Lightair window or use File › Install Package…. It then appears in the widget list under From packages, ready to add to any scene. See Packages.

Lightair works out which service a widget was written for from its script: one that listens on document (onLoad, onEventReceived) is treated as a Streamlabs widget, anything else as a StreamElements widget. Then it gives the widget what that service would:

  • StreamElements widgets get onWidgetLoad with their field values and this stream’s recent events, onEventReceived with StreamElements’ listener names (message, follower-latest, subscriber-latest, tip-latest, cheer-latest, raid-latest, and message deletions), and onSessionUpdate. SE_API.store keeps its data in Lightair. jQuery is loaded, as it is on StreamElements.
  • Streamlabs widgets get onLoad with their field values and onEventReceived with chat messages and alerts.
  • {{fieldName}} in the HTML, CSS or JavaScript is replaced with the field’s value, as on both services.

Events come from the channels named in your destinations’ Chat fields, and tips from the services connected under Settings › Connections. A widget that talks to StreamElements’ or Streamlabs’ own servers for anything else needs those services as before.

Select the widget. The Inspector shows its fields as settings: text, numbers, colours, choices, switches, pictures and sounds, and buttons (a button field sends the widget a widget-button event). Each change reloads the widget with the new values and can be undone.

As with built-in widgets:

  • Send a test offers chat messages, a message with emotes, and alerts, if the widget listens for events.
  • Placeholder shows samples while you set it up, if the widget listens for events.
  • Gets events from chooses the platforms it listens to.
  • The link button copies its address, to use it in OBS or a browser on this computer.

See Widgets.

Under CODE, the widget’s HTML, CSS, JS and Fields are in tabs you can edit; the canvas shows changes a moment after you stop typing. The buttons beside the tabs:

  • Open its files in a folder: edit them in any editor, and each save shows in Lightair at once.
  • Export as a .lwidget package: one file to share or use elsewhere.
  • Edit in a large editor: opens the code beside the canvas.

Writing widgets for Lightair itself, with its own event bridge, is covered in Build a widget.