Logo

Select

Select provides a dropdown interface for choosing from a list of options, supporting both single and multiple selection modes. It offers extensive customization capabilities including search functionality, custom templates, and comprehensive form integration.
Key features:
  • Flexible selection modes: Single selection by default, with optional multi-select capability
  • Option containers: Uses Option components to define selectable items with separate values and labels
  • Search functionality: Optional filtering to quickly find options in large lists
  • Custom templates: Configurable option display, value presentation, and empty state templates
  • Dynamic options: Supports both static Option children and dynamic lists via Items.

Using Select

The component accepts Option components as children defining a particular option's label-value pair. Option requires a value property and while also having a label that is displayed in the list. If the label is not specified value is shown.
<App>
  <Select>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: using Select
<App>
  <Select>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
You can use Select with dynamic options:
<App>
  <Select>
    <Items data="{['one', 'two', 'three']}" >
      <Option value="{$itemIndex}" label="{$item}" />
    </Items>
  </Select>
</App>
Example: using Select with dynamic options
<App>
  <Select>
    <Items data="{['one', 'two', 'three']}" >
      <Option value="{$itemIndex}" label="{$item}" />
    </Items>
  </Select>
</App>
Context variables available during execution:
  • $item: Represents the current option's data (label and value properties)
  • $itemContext: Provides utility methods like removeItem() for multi-select scenarios

Properties

autoFocus (default: false)

If this property is set to true, the component gets the focus automatically when displayed.

dropdownHeight

This property sets the height of the dropdown list. If not set, the height is determined automatically.
<App>
  <Select dropdownHeight="180px">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
    <Option value="opt4" label="fourth"/>
    <Option value="opt5" label="fifth"/>
    <Option value="opt6" label="sixth"/>
    <Option value="opt7" label="seventh"/>
    <Option value="opt8" label="eighth"/>
    <Option value="opt9" label="ninth"/>
    <Option value="opt10" label="tenth"/>
    <Option value="opt11" label="eleventh"/>
    <Option value="opt12" label="twelfth"/>
  </Select>
</App>
Example: dropdownHeight
<App>
  <Select dropdownHeight="180px">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
    <Option value="opt4" label="fourth"/>
    <Option value="opt5" label="fifth"/>
    <Option value="opt6" label="sixth"/>
    <Option value="opt7" label="seventh"/>
    <Option value="opt8" label="eighth"/>
    <Option value="opt9" label="ninth"/>
    <Option value="opt10" label="tenth"/>
    <Option value="opt11" label="eleventh"/>
    <Option value="opt12" label="twelfth"/>
  </Select>
</App>

emptyListTemplate

This optional property provides the ability to customize what is displayed when the list of options is empty.
Click on the second field to see the custom empty list indicator.
<App>
  <VStack>
    <Text value="Default:" />
    <Select />
  </VStack>
  <VStack>
    <Text value="Custom:" />
    <Select>
      <property name="emptyListTemplate">
        <Text variant="strong" value="Nothing to see here!" />
      </property>
    </Select>
  </VStack>
</App>
Example: emptyListTemplate
<App>
  <VStack>
    <Text value="Default:" />
    <Select />
  </VStack>
  <VStack>
    <Text value="Custom:" />
    <Select>
      <property name="emptyListTemplate">
        <Text variant="strong" value="Nothing to see here!" />
      </property>
    </Select>
  </VStack>
</App>

enabled (default: true)

This boolean property value indicates whether the component responds to user events (true) or not (false).
<App>
  <Select enabled="false" />
</App>
Example: enabled
<App>
  <Select enabled="false" />
</App>

initialValue

This property sets the component's initial value.
<App>
  <Select initialValue="opt3">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: initialValue
<App>
  <Select initialValue="opt3">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

inProgress (default: false)

This property indicates whether the component is in progress. It can be used to show a loading message.

inProgressNotificationMessage (default: "")

This property indicates the message to display when the component is in progress.

label

This property sets the label of the component. If not set, the component will not display a label.

labelBreak (default: false)

This boolean value indicates whether the Select label can be split into multiple lines if it would overflow the available label width.

labelPosition (default: "top")

Places the label at the given position of the component.
Available values:
ValueDescription
startThe left side of the input (left-to-right) or the right side of the input (right-to-left)
endThe right side of the input (left-to-right) or the left side of the input (right-to-left)
topThe top of the input (default)
bottomThe bottom of the input

labelWidth

This property sets the width of the Select component's label. If not defined, the label's width will be determined by its content and the available space.

multiSelect (default: false)

The true value of the property indicates if the user can select multiple items.
<App>
  <Select multiSelect="true" dropdownHeight="180px" >
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
    <Option value="opt4" label="fourth"/>
    <Option value="opt5" label="fifth"/>
    <Option value="opt6" label="sixth"/>
    <Option value="opt7" label="seventh"/>
    <Option value="opt8" label="eighth"/>
    <Option value="opt9" label="ninth"/>
    <Option value="opt10" label="tenth"/>
    <Option value="opt11" label="eleventh"/>
    <Option value="opt12" label="twelfth"/>
  </Select>
</App>
Example: multiSelect
<App>
  <Select multiSelect="true" dropdownHeight="180px" >
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
    <Option value="opt4" label="fourth"/>
    <Option value="opt5" label="fifth"/>
    <Option value="opt6" label="sixth"/>
    <Option value="opt7" label="seventh"/>
    <Option value="opt8" label="eighth"/>
    <Option value="opt9" label="ninth"/>
    <Option value="opt10" label="tenth"/>
    <Option value="opt11" label="eleventh"/>
    <Option value="opt12" label="twelfth"/>
  </Select>
</App>

optionLabelTemplate

This property allows replacing the default template to display an option in the dropdown list.
In the template definition, you can use the $item context property to access the particular item's label and value.
<App>
  <Select initialValue="{0}" placeholder="Select..." searchable>
    <property name="optionLabelTemplate">
      <HStack
        paddingHorizontal="$padding-tight"
        border="2px dotted $color-primary-500">
        <Text>{$item.label}</Text>
      </HStack>
    </property>
    <Option value="{0}" label="zero"/>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: optionLabelTemplate
<App>
  <Select initialValue="{0}" placeholder="Select..." searchable>
    <property name="optionLabelTemplate">
      <HStack
        paddingHorizontal="$padding-tight"
        border="2px dotted $color-primary-500">
        <Text>{$item.label}</Text>
      </HStack>
    </property>
    <Option value="{0}" label="zero"/>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

optionTemplate

This property allows replacing the default template to display an option in the dropdown list.
<App>
  <Select>
    <property name="optionTemplate">
      <HStack verticalAlignment="center" gap="$space-0_5">
        <Icon name="info" />
        <Text value="{$item.label}" variant="strong" />
      </HStack>
    </property>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: optionTemplate
<App>
  <Select>
    <property name="optionTemplate">
      <HStack verticalAlignment="center" gap="$space-0_5">
        <Icon name="info" />
        <Text value="{$item.label}" variant="strong" />
      </HStack>
    </property>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

placeholder (default: "")

An optional placeholder text that is visible in the input field when its empty.
<App>
  <Select placeholder="Please select an item">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: placeholder
<App>
  <Select placeholder="Please select an item">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

readOnly (default: false)

Set this property to true to disallow changing the component value.

required (default: false)

Set this property to true to indicate it must have a value before submitting the containing form.

searchable (default: false)

This property enables the search functionality in the dropdown list.

validationStatus (default: "none")

This property allows you to set the validation status of the input component.
Available values:
ValueDescription
validVisual indicator for an input that is accepted
warningVisual indicator for an input that produced a warning
errorVisual indicator for an input that produced an error
<App>
  <Select />
  <Select validationStatus="valid" />
  <Select validationStatus="warning" />
  <Select validationStatus="error" />
</App>
Example: validationStatus
<App>
  <Select />
  <Select validationStatus="valid" />
  <Select validationStatus="warning" />
  <Select validationStatus="error" />
</App>

valueTemplate

This property allows replacing the default template to display a selected value when multiple selections (multiSelect is true) are enabled.
In the template definition, you can use the $item context property to access the particular item's label and value. The $itemContext property provides a removeItem method to delete a value from the current selection.
<App>
  <Select initialValue="{0}" placeholder="Select..." multiSelect>
    <property name="valueTemplate">
      <HStack
        paddingLeft="$padding-tight"
        border="2px dotted $color-primary-500"
        verticalAlignment="center">
        <Text>{$item.label}</Text>
        <Button
          variant="ghost"
          icon="close"
          size="xs"
          onClick="$itemContext.removeItem()"/>
      </HStack>
    </property>
    <Option value="{0}" label="zero"/>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: valueTemplate
<App>
  <Select initialValue="{0}" placeholder="Select..." multiSelect>
    <property name="valueTemplate">
      <HStack
        paddingLeft="$padding-tight"
        border="2px dotted $color-primary-500"
        verticalAlignment="center">
        <Text>{$item.label}</Text>
        <Button
          variant="ghost"
          icon="close"
          size="xs"
          onClick="$itemContext.removeItem()"/>
      </HStack>
    </property>
    <Option value="{0}" label="zero"/>
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

Events

didChange

This event is triggered when value of Select has changed.
<App>
  <variable name="newValue" value="(none)" />
  <Text value="{newValue}" />
  <Select onDidChange="(newItem) => newValue = newItem">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: didChange
<App>
  <variable name="newValue" value="(none)" />
  <Text value="{newValue}" />
  <Select onDidChange="(newItem) => newValue = newItem">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

gotFocus

This event is triggered when the Select has received the focus.
<App>
  <variable name="isFocused" value="{false}" />
  <Text value="Input control is focused: {isFocused}" />
  <Select
    onGotFocus="isFocused = true"
    onLostFocus="isFocused = false">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: gotFocus/lostFocus
<App>
  <variable name="isFocused" value="{false}" />
  <Text value="Input control is focused: {isFocused}" />
  <Select
    onGotFocus="isFocused = true"
    onLostFocus="isFocused = false">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

lostFocus

This event is triggered when the Select has lost the focus.

Exposed Methods

focus

This method focuses the Select component. You can use it to programmatically focus the component.
Signature: focus(): void
<App>
  <Button label="Focus Input" onClick="inputControl.focus()" />
  <Select id="inputControl">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>
Example: focus()
<App>
  <Button label="Focus Input" onClick="inputControl.focus()" />
  <Select id="inputControl">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
</App>

reset

This method resets the component to its initial value, or clears the selection if no initial value was provided.
Signature: reset(): void

setValue

This API sets the value of the Select. You can use it to programmatically change the value.
Signature: setValue(value: string | string[] | undefined): void
  • value: The new value to set. Can be a single value or an array of values for multi-select.
<App>
  <Select id="inputControl">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
  <HStack>
    <Button
      label="Select 2nd Item"
      onClick="inputControl.setValue('opt2')" />
    <Button
      label="Remove Selection"
      onClick="inputControl.setValue('')" />
  </HStack>
</App>
Example: setValue()
<App>
  <Select id="inputControl">
    <Option value="opt1" label="first"/>
    <Option value="opt2" label="second"/>
    <Option value="opt3" label="third"/>
  </Select>
  <HStack>
    <Button
      label="Select 2nd Item"
      onClick="inputControl.setValue('opt2')" />
    <Button
      label="Remove Selection"
      onClick="inputControl.setValue('')" />
  </HStack>
</App>

value

This API retrieves the current value of the Select. You can use it to get the value programmatically.
Signature: get value(): string | string[] | undefined

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
backgroundColor-item-Select$backgroundColor-dropdown-item$backgroundColor-dropdown-item
backgroundColor-item-Select--active$backgroundColor-dropdown-item--active$backgroundColor-dropdown-item--active
backgroundColor-item-Select--hover$backgroundColor-dropdown-item--hover$backgroundColor-dropdown-item--hover
backgroundColor-menu-Select$color-surface-raised$color-surface-raised
backgroundColor-menu-Select$color-surface-raised$color-surface-raised
backgroundColor-Select--disablednonenone
backgroundColor-Select-badge$color-primary-500$color-primary-500
backgroundColor-Select-badge$color-primary-500$color-primary-500
backgroundColor-Select-badge--active$color-primary-500$color-primary-500
backgroundColor-Select-badge--active$color-primary-500$color-primary-500
backgroundColor-Select-badge--hover$color-primary-400$color-primary-400
backgroundColor-Select-badge--hover$color-primary-400$color-primary-400
backgroundColor-Select-defaultnonenone
backgroundColor-Select-default--hovernonenone
backgroundColor-Select-errornonenone
backgroundColor-Select-error--hovernonenone
backgroundColor-Select-successnonenone
backgroundColor-Select-success--hovernonenone
backgroundColor-Select-warningnonenone
backgroundColor-Select-warning--hovernonenone
borderColor-menu-Select$borderColor$borderColor
borderColor-menu-Select$borderColor$borderColor
borderColor-Select--disabledinitialinitial
borderColor-Select--disabledinitialinitial
borderColor-Select-defaultnonenone
borderColor-Select-default--hovernonenone
borderColor-Select-errornonenone
borderColor-Select-error--hovernonenone
borderColor-Select-successnonenone
borderColor-Select-success--hovernonenone
borderColor-Select-warningnonenone
borderColor-Select-warning--hovernonenone
borderRadius-menu-Select$borderRadius$borderRadius
borderRadius-menu-Select$borderRadius$borderRadius
borderRadius-Select-badge$borderRadius$borderRadius
borderRadius-Select-defaultnonenone
borderRadius-Select-errornonenone
borderRadius-Select-successnonenone
borderRadius-Select-warningnonenone
borderStyle-Select-defaultnonenone
borderStyle-Select-errornonenone
borderStyle-Select-successnonenone
borderStyle-Select-warningnonenone
borderWidth-menu-Select1px1px
borderWidth-menu-Select1px1px
borderWidth-Select-defaultnonenone
borderWidth-Select-errornonenone
borderWidth-Select-successnonenone
borderWidth-Select-warningnonenone
boxShadow-menu-Select$boxShadow-md$boxShadow-md
boxShadow-menu-Select$boxShadow-md$boxShadow-md
boxShadow-Select-defaultnonenone
boxShadow-Select-default--hovernonenone
boxShadow-Select-errornonenone
boxShadow-Select-error--hovernonenone
boxShadow-Select-successnonenone
boxShadow-Select-success--hovernonenone
boxShadow-Select-warningnonenone
boxShadow-Select-warning--hovernonenone
fontSize-placeholder-Select-defaultnonenone
fontSize-placeholder-Select-errornonenone
fontSize-placeholder-Select-successnonenone
fontSize-placeholder-Select-warningnonenone
fontSize-Selectnonenone
fontSize-Select-badge$fontSize-small$fontSize-small
fontSize-Select-badge$fontSize-small$fontSize-small
fontSize-Select-defaultnonenone
fontSize-Select-errornonenone
fontSize-Select-successnonenone
fontSize-Select-warningnonenone
opacity-Select--disabled0.50.5
opacity-text-item-Select--disabled0.50.5
outlineColor-Select-default--focusnonenone
outlineColor-Select-error--focusnonenone
outlineColor-Select-success--focusnonenone
outlineColor-Select-warning--focusnonenone
outlineOffset-Select-default--focusnonenone
outlineOffset-Select-error--focusnonenone
outlineOffset-Select-success--focusnonenone
outlineOffset-Select-warning--focusnonenone
outlineStyle-Select-default--focusnonenone
outlineStyle-Select-error--focusnonenone
outlineStyle-Select-success--focusnonenone
outlineStyle-Select-warning--focusnonenone
outlineWidth-Select-default--focusnonenone
outlineWidth-Select-error--focusnonenone
outlineWidth-Select-success--focusnonenone
outlineWidth-Select-warning--focusnonenone
padding-item-Selectnonenone
padding-Selectnonenone
paddingBottom-item-Selectnonenone
paddingBottom-Selectnonenone
paddingHorizontal-item-Select$space-2$space-2
paddingHorizontal-Select$space-2$space-2
paddingHorizontal-Select-badge$space-2_5$space-2_5
paddingLeft-item-Selectnonenone
paddingLeft-Selectnonenone
paddingRight-item-Selectnonenone
paddingRight-Selectnonenone
paddingTop-item-Selectnonenone
paddingTop-Selectnonenone
paddingVertical-item-Select$space-2$space-2
paddingVertical-Select$space-2$space-2
paddingVertical-Select-badge$space-0_5$space-0_5
textColor-indicator-Selectnonenone
textColor-item-Select--disabled$color-surface-200$color-surface-200
textColor-placeholder-Selectnonenone
textColor-placeholder-Select-defaultnonenone
textColor-placeholder-Select-errornonenone
textColor-placeholder-Select-successnonenone
textColor-placeholder-Select-warningnonenone
textColor-Select--disablednonenone
textColor-Select-badge$color-surface-50$color-surface-50
textColor-Select-badge$color-surface-50$color-surface-50
textColor-Select-badge--activenonenone
textColor-Select-badge--hovernonenone
textColor-Select-defaultnonenone
textColor-Select-default--hovernonenone
textColor-Select-errornonenone
textColor-Select-error--hovernonenone
textColor-Select-successnonenone
textColor-Select-success--hovernonenone
textColor-Select-warningnonenone
textColor-Select-warning--hovernonenone
This site is an XMLUI™ app.