Toggle Button

A button to toggle a boolean value. It supports changing an icon based on the value.

Properties

Available properties for Toggle Button with supported data types or values. You can write JavaScript almost anywhere in Retool to manipulate or read information about components.

NameTypeDescriptionvalueboolean

The current value.

disabledboolean

Whether user input, interaction, or selection is disabled.

hiddenboolean

Whether the component is visible.

horizontalAlign'left' | 'center' | 'right' | 'stretch'

The horizontal alignment of the contents.

iconForFalseIconKey

The icon to display when value is false.

iconForTrueIconKey

The icon to display when value is true.

iconPosition'left' | 'right' | 'replace'

The position of the icon relative to the label.

loaderPosition'auto' | 'replace' | 'left' | 'right'

The position of the loading indicator if loading is true.

loadingboolean

Whether to display a loading indicator.

maintainSpaceWhenHiddenboolean

Whether the component takes up space on the canvas if hidden is true.

marginstring

The amount of margin to render outside of the component.

showInEditorboolean

Whether the component remains visible in the editor if hidden is true.

textstring

The primary text content.

tooltipTextstring

The text to display in a tooltip on hover or focus.

Events

Events are triggered by user interactions with Toggle Button. Use event handling to trigger queries or other actions in response to events.

NameDescriptionChange

A user changes the current value.

False

A user sets the current value to false.

True

A user sets the current value to true.

Methods

Methods for interacting with Toggle Button. You can write JavaScript almost anywhere in Retool and use methods to manipulate data or components.

NameDescriptionsetValue(value: boolean)

Set the current value.

toggle()

Toggle the current value between true and false.

clearValue()

Clear the current value.

scrollIntoView(options: any)

Scrolls the canvas or parent container so that the selected component appears in the visible area.

setHidden(hidden: boolean)

Set the hidden value to toggle whether the component is visible. Defaults to true without a parameter.

setDisabled(disabled: boolean)

Set the disabled value to toggle whether the input field is disabled. Defaults to true without a parameter.

resetValue()

Reset value to the default value.