Modules · Interface

Button

Buttons that change state. A button names a reactive value and how to change it, and pressing it performs that change. This is reversibility: any value can be set, and a button is a place a set happens. Each button takes a content closure for its label. These build on Dom.Event.Set.

Contents

Functions

Functions

Button.Integer.Decrement

A button that subtracts one from an integer value when pressed.

Parameters

NameTypeDescription
settableReactive numberThe integer to lower by one.
contentfunctionA closure for the button's label.

Example

const count = Reactive.State(Maths.Integer)(10);
Button.Integer.Decrement(count, () => {
  Content.Text("Down");
});
A button that decrements a count

Button.Integer.Increment

A button that adds one to an integer value when pressed.

Parameters

NameTypeDescription
settableReactive numberThe integer to raise by one.
contentfunctionA closure for the button's label.

Example

const count = Reactive.State(Maths.Integer)(0);
Button.Integer.Increment(count, () => {
  Content.Text(`Clicked ${count.value} times`);
});
The home-page counter that increments on press

Button.Set

A button that sets a value to a fixed new value when pressed.

Parameters

NameTypeDescription
settableReactive valueThe value to set.
newValueanyWhat to set it to when the button is pressed.
contentfunctionA closure for the button's label.

Example

const open = Reactive.State(Logic.Maybe)(false);
Button.Set(open, true, () => {
  Content.Text("Open");
});
A button that sets a value to true