Skip to content

Widget.parameters

Widget.parameters reads the parameters: they are the values the viewer changes in the widget menu (you declare them in menu of manifest.json). They are read with the method that matches their type, with a default value when there is none:

  • string(name, fallback?): text.
  • bool(name, fallback?): true for "true" or "1"; false for "false" or "0".
  • int(name, fallback?): integer.
  • number(name, fallback?): number with decimals.
  • color(name, fallback?): color #RGB, #RRGGBB or #RRGGBBAA; if invalid, the default.
  • font(name, fallback?): a value for font-family; if it is a Google Font and is in the menu options, it loads it.
  • asset(name): the URL of the file chosen in an image, video or audio field; "" with “No file”.

In this order: the URL first, then what was saved with the OBS URL in “Configure”, and finally the menu default. That is why changing a parameter in “Configure” does not force you to paste another URL in OBS.

const size = Widget.parameters.int("fontSize", 24);
const color = Widget.parameters.color("textColor", "#ffffff");
document.body.style.fontSize = `${size}px`;
document.body.style.color = color;

A file chosen in the menu is passed as is to Widget.assets:

Widget.assets.play(Widget.parameters.asset("followSound"));