Reference machines
toggle
interface 2 type 3 function 1
# CreateToggleInput
Construction input.
Members
disabled?optional disabled?: booleanConstruct the machine in the disabled state. Defaults to
false.initial?optional initial?: booleanInitial pressed value. Defaults to
false.
# ToggleContext
Reactive state surfaced to consumers.
Members
pressedpressed: booleanWhether the toggle is currently pressed. Mirrored as
aria-pressed.togglestoggles: numberNumber of user-initiated toggles since construction. Useful for analytics and for detecting infinite-loop bugs in test fixtures.
# ToggleEvent
ToggleEvent = { type: "TOGGLE"; } | { pressed: boolean; type: "SET"; } | { type: "DISABLE"; } | { type: "ENABLE"; }All events the Toggle machine can receive.
# ToggleMachine
ToggleMachine = Machine<ToggleContext, ToggleEvent, ToggleState>A running Toggle machine instance.
# ToggleState
ToggleState = "unpressed" | "pressed" | "disabled"State names the machine can be in.
# createToggleMachine ( )
createToggleMachine(input?): ToggleMachineConstruct a fresh Toggle machine.
Parameters
input?CreateToggleInput = {}
Returns
ToggleMachine