skip to content

Switch

Takes an input of type checkbox and uses it to change any target prop of any element.

class
Switch
extends
Set
tag
<switch-blam>
see

Props

name type default description
event string input

Do not supply an event prop for this element. It must use the child input’s input event.

value string null

If a value is supplied, when the input in checked, the value is applied. When unchecked, it reapplies the prop’s initial value. If no value is applied the value is considered Boolean.

reverse false

Whether to reverse the polarity of the checked state. Useful where the label and prop seem to contradict one another. For example, a switch labeled “filter” that turns a filter on by making its bypass property false.

ramp number

In beats. Where the prop is an audioParam, whether to ramp the value. For example, for gain, whether to fade/slide between the start and end values.

revert boolean false

When revert is applied, values do not stick. Once set, the next event reverts them to the original value (the one taken from the element during initialization). Used with a low chance, you create the effect of a regular value that just occasionally, and momentarily, strays.

once boolean false

Whether to only handle the event one time. Interesting, compositionally, when paired with a low chance.

from string

A CSS selector representing all elements from which events will be listened to. If not set, the node array defaults to the element’s defaultFrom function’s return value.

to string

A CSS selector representing all elements to affect in response to the event. If not set, the node array defaults to the element’s defaultTo function’s return value.

prop string null

The property (which may be a method or map to an audioParam) to affect at the event.

bypass boolean false

Whether to stop responding to events as they happen.

chance boolean 1

The probability that the event will be responded to. From 0 to 1.

Examples

Examples that use the Switch element: