Widgets

button

button(text?: string): Button;

A generic GUI button component.

Parameters

OptionTypeDescriptionRequired
textstringThe text of the button

Streams

NameTypeDescriptionHold
$textstringStream defining the button text
$type'default' | 'success' | 'warning' | 'danger'Stream defining the button type
$clickundefinedStream of click events
$pressedbooleanStream of binary events indicating if the button is pressed
$loadingbooleanStream of binary events indicating if the button is in loading mode
$loadingbooleanStream of binary events indicating if the button is in loading mode
$disabledbooleanStream defining if the input is disabled.

Screenshot

Screenshot of the button component

Example

const capture = button('Hold to record instances');
capture.title = 'Capture instances to the training set';

capture.$click.subscribe((x) => console.log('button $click:', x));
capture.$pressed.subscribe((x) => console.log('button $pressed:', x));

number

number(defaultValue?: number): Number;

A generic GUI number input component.

Parameters

OptionTypeDescriptionrequired
defaultValuenumberInitial value. Defaults to 0.

Streams

NameTypeDescriptionHold
$valuenumberStream defining the input's value
$disabledbooleanStream defining if the input is disabled.

Screenshot

Screenshot of the number component

Example

const epochs = number(30);
epochs.title = 'Number of Epochs';

epochs.$value.subscribe(console.log);

numberArray

numberArray(defaultValue?: number[]): NumberArray;

A generic GUI number array input component.

Parameters

OptionTypeDescriptionrequired
defaultValuenumber[]Initial value. Defaults to [].

Streams

NameTypeDescriptionHold
$valuenumber[]Stream defining the input's value
$disabledbooleanStream defining if the input is disabled.

Screenshot

Screenshot of the number-array component

Example

const neuronsPerLayer = numberArray([64, 32, 16]);
neuronsPerLayer.title = 'Number of Neurons per Layer';

neuronsPerLayer.$value.subscribe(console.log);

select

select(options: string[], value?: string): Select;

A generic GUI Select component.

Parameters

OptionTypeDescriptionRequired
optionsstring[]The select menu options
valuestringThe default value (by default, the first option)

Streams

NameTypeDescriptionHold
$optionsstring[]Stream of menu options
$valuestringStream of selected value

Screenshot

Screenshot of the select component

Example

const sel = select(['one', 'two', 'three'], 'two');
sel.$value.subscribe((x) => console.log('sel $value:', x));

slider

slider({
  values: number[],
  min: number,
  max: number,
  step: number,
  range: boolean | 'min' | 'max',
  float: boolean,
  vertical: boolean,
  pips: boolean,
  pipstep: number,
  formatter: (x: unknown) => unknown,
  continuous: boolean,
}): Slider;

A generic slider widget, allowing multiple thumbs.

Parameters

OptionTypeDescriptionRequiredDefault
valuesnumber[]The default values[0.2]
minnumberminimum value0
maxnumbermaximum value1
stepnumberstep size0.01
rangeboolean | 'min' | 'max'Specifies the slider bar display. If false, no bar is displayed. If true, the bar is displayed as a range between several values. If 'min' (resp. 'max'), the slider bar is displayed from the minimum (resp. 'maximum') value.'min'
floatbooleanspecifies if the value should be displayed in a floating indicator on hovertrue
verticalbooleandisplay the slider verticallyfalse
pipsbooleandisplay pips (ticks)false
pipstepnumberPip step sizeundefined
formatter(x: unknown) => unknownThe function used for formatting the pips and floating indicator(x) => x
continuousbooleanSpecify if values should be update continuously or on mouse release.true

Streams

NameTypeDescriptionHold
$valuesstringStream of selected value
$minstringStream of selected value
$maxstringStream of selected value
$stepstringStream of selected value

Screenshot

Screenshot of the slider component

Example

const slider = slider({
  values: [2, 8],
  min: 0,
  max: 10,
  pips: true,
  step: 1,
  range: true,
});
slider.$values.subscribe((x) => console.log('slider $values:', x));

text

text(initial?: string): Text;

A generic GUI text display component accepting HTL strings.

Parameters

OptionTypeDescriptionRequired
initialstringInitial text

Streams

NameTypeDescriptionHold
$valuebooleanStream defining the text content

Screenshot

Screenshot of the toggle component

Example

const t = text(
  `Just some HTML text content...<br>
  Accepts HTML: <a href="https://marcelle.dev">Click me!</a>`,
);

textArea

textArea(defaultValue: string, placeholder: string): TextArea;

A generic GUI text area component.

Parameters

OptionTypeDescriptionRequired
defaultValuestringInitial value
placeholderstringPlaceholder text

Streams

NameTypeDescriptionHold
$valuestringStream defining the textarea's value
$disabledbooleanStream defining if the textarea is disabled

Screenshot

Screenshot of the text-area component

Example

const comments = textArea('', 'Enter some comments');
comments.$value.subscribe(console.log);

textInput

textInput(defaultValue?: string): TextInput;

A generic GUI text input component.

Parameters

OptionTypeDescriptionRequired
defaultValuestringInitial value

Streams

NameTypeDescriptionHold
$valuestringStream defining the input's value
$disabledbooleanStream defining if the input is disabled

Screenshot

Screenshot of the text-input component

Example

const label = textInput('myLabel');
label.title = 'Instance label';

label.$value.subscribe(console.log);

toggle

toggle(text?: string): Toggle;

A generic GUI toggle (switch) component.

Parameters

OptionTypeDescriptionRequired
textstringThe text of the togggle

Streams

NameTypeDescriptionHold
$textbooleanStream defining the toggle text
$checkedbooleanStream defining if the toggle is checked
$disabledbooleanStream defining if the toggle is disabled

Screenshot

Screenshot of the toggle component

Example

const tog = toggle('Toggle Real-Time Prediction');
tog.$checked.subscribe((x) => console.log('toggle $checked:', x));