Segmented Control

A segmented button to select a single value. It can perform validation of required field and custom rules.

Properties

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

NameTypeDescriptionvaluestring | number | boolean | null | undefined

The current value.

data{ [key: string]: unknown }[]

The source data for the component.

disabledboolean

Whether user input, interaction, or selection is disabled.

disabledByIndexboolean[]

A list of boolean values for each item, by index, that reflect whether they are disabled.

formDataKeystring

The key used by a Form component to assign default values to input fields using form.initialData, and to construct the form.data property.

hiddenboolean

Whether the component is visible.

hideValidationMessageboolean

Whether to hide the validation message if the invalid is true.

iconByIndexIconKey[]

A list of icons for each item, by index.

iconPositionByIndex('left' | 'right' | 'replace')[]

A list of icon positions for each item, by index, relative to labels.

invalidboolean

Whether the current value has failed any validation rules.

itemMode'dynamic' | 'static'

The configuration mode for option lists. Either dynamic for mapped options or static for manual options.

labelstring

The text to display as a label for the input field.

labelAlign'left' | 'right'

The horizontal alignment of the label.

labelCaptionstring

The additional text to display with the label.

labelPosition'left' | 'top'

The position of the label relative to the input field.

labelWidthnumber

The label width, in the unit specified in labelWidthUnit.

labelWidthUnit'%' | 'px' | 'col'

The specified units for labelWidth.

labelWrapboolean

Whether the label can wrap to multiple lines.

labelsstring[]

A list of labels for each item. Falls back to the corresponding value if no label is provided.

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.

paddingType'dense' | 'spacious'

This determines the padding type of the segmented control.

requiredboolean

Whether the input is required for validation.

selectedIndexnumber | null

The currently selected value, by index.

selectedItemunknown | null

The currently selected item.

selectedLabelstring

The label of the currently selected value, by index.

showInEditorboolean

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

tooltipTextstring

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

validationMessagestring

The validation message to display if the input is invalid.

values(string | number | boolean | null | undefined)[]

A list of possible values.

deprecatedLabelsDeprecatedstring[]

Events

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

NameDescriptionChange

A user changes the current value.

Methods

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

NameDescriptionsetValue(value: boolean | string | number | void, strict: any)

Set the current value.

clearValue()

Clear the current value.

scrollIntoView(options: any)

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

validate()

Validates the value of the input field.

clearValidation()

Clear the validation message from the input field.

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.

focus()

Set focus on the input field.

Related components